Skip to content

Commit 53d717f

Browse files
authored
fix(pds-input): style native search clear button with custom icon (#665)
1 parent 2e5e248 commit 53d717f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

libs/core/src/components/pds-input/pds-input.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,15 @@
327327
white-space: nowrap;
328328
width: 1px;
329329
}
330+
331+
// Custom styling for the search clear (x) button
332+
.pds-input__field::-webkit-search-cancel-button {
333+
appearance: none;
334+
background-color: var(--pds-input-placeholder-color);
335+
cursor: pointer;
336+
height: var(--pine-dimension-sm);
337+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.646 3.646a.5.5 0 0 1 .708 0L8 7.293l3.646-3.647a.5.5 0 0 1 .708.708L8.707 8l3.647 3.646a.5.5 0 0 1-.708.708L8 8.707l-3.646 3.647a.5.5 0 0 1-.708-.708L7.293 8 3.646 4.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E");
338+
mask-size: contain;
339+
width: var(--pine-dimension-sm);
340+
}
341+

libs/core/src/components/pds-input/stories/pds-input.stories.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ Email.args = {
7171
value: 'user123@test.com'
7272
};
7373

74+
export const Search = BaseTemplate.bind({});
75+
Search.args = {
76+
componentId: 'pds-input-search-example',
77+
label: 'Search',
78+
type: 'search',
79+
placeholder: 'Search...',
80+
};
81+
7482
export const Required = BaseTemplate.bind({});
7583
Required.args = {
7684
componentId: 'pds-input-required-example',

libs/react/src/components/react-component-lib/createComponent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export const createReactComponent = <
2626
defineCustomElement?: () => void
2727
) => {
2828
if (defineCustomElement !== undefined) {
29-
defineCustomElement();
29+
// Guard against double-registration when CDN and @pine-ds/react are both loaded
30+
if (typeof customElements !== 'undefined' && !customElements.get(tagName)) {
31+
defineCustomElement();
32+
}
3033
}
3134

3235
const displayName = dashToPascalCase(tagName);

0 commit comments

Comments
 (0)