Skip to content

Commit c673ef2

Browse files
authored
fix: searchbar clear button (#1892)
<!-- Hello 👋 Thank you for submitting a pull request. To help us merge your PR, make sure to follow the instructions below: - Create or update the tests - Create or update the documentation at https://github.com/strapi/documentation - Refer to the issue you are closing in the PR description: Fix #issue - Specify if the PR is ready to be merged or work in progress (by opening a draft PR) Please ensure you read the Contributing Guide: https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md --> ### What does it do? Describe the technical changes you did. ### Why is it needed? Describe the issue you are solving. ### How to test it? Provide information about the environment and the path to verify the behaviour. ### Related issue(s)/PR(s) Let us know if this is related to any issue/pull request
2 parents 7904976 + 7767141 commit c673ef2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: .changeset/honest-crabs-crash.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@strapi/design-system': major
3+
'@strapi/icons': major
4+
'@strapi/ui-primitives': major
5+
---
6+
7+
fix searchbar component

Diff for: packages/design-system/src/components/Searchbar/Searchbar.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface SearchbarProps extends Field.InputProps {
6262
}
6363

6464
export const Searchbar = React.forwardRef<HTMLInputElement, SearchbarProps>(
65-
({ name, children, value = '', onClear, clearLabel, ...props }, ref) => {
65+
({ name, children, value = '', onClear, clearLabel = 'Clear', ...props }, ref) => {
6666
const inputRef = React.useRef<HTMLInputElement>(null!);
6767
const isCompleting = value.length > 0;
6868

@@ -87,17 +87,17 @@ export const Searchbar = React.forwardRef<HTMLInputElement, SearchbarProps>(
8787
startAction={<SearchIcon aria-hidden />}
8888
endAction={
8989
isCompleting ? (
90-
<Field.Action
91-
label={clearLabel}
90+
<IconButton
9291
onClick={handleClear}
9392
onMouseDown={(e) => {
9493
e.preventDefault();
9594
}}
95+
label={clearLabel}
96+
size="XS"
97+
variant="ghost"
9698
>
97-
<IconButton label="Clear" size="XS" variant="ghost">
98-
<CloseIcon />
99-
</IconButton>
100-
</Field.Action>
99+
<CloseIcon />
100+
</IconButton>
101101
) : undefined
102102
}
103103
{...props}

0 commit comments

Comments
 (0)