Skip to content

Commit

Permalink
๐ŸšธSearch: remove clear button when disabled (#3054)
Browse files Browse the repository at this point in the history
* ๐Ÿ› Fixed so that clear-icon is not visible in disabled field (#3053)

* ๐Ÿ› Added dependency in useEffect (#3053)

* ๐Ÿ› Fixed problem with registering change to disabled (#3053)
  • Loading branch information
denektenina authored Sep 18, 2023
1 parent 6609b34 commit 3de9c75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/eds-core-react/src/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(function Search(
const [showClear, setShowClear] = useState(Boolean(rest.defaultValue))

useEffect(() => {
if (rest.value) {
if (rest.disabled) {
setShowClear(false)
} else if (rest.value) {
setShowClear(Boolean(rest.value))
}
}, [rest.value])
}, [rest.value, rest.disabled])

const clearInputValue = () => {
const input = inputRef.current
Expand Down

0 comments on commit 3de9c75

Please sign in to comment.