(fix) O3-2158: Clear order basket search input and trap focus when search gets reset. #1322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix)O3-2158:Clear order basket search input and trap focus when search gets reset. i Declare a ref in the Drug Search component that tracks the Search input using the useRef hook and passed it down in Drug Search Result component and Update the logic in it to to accept the ref as a prop. Create a boolean state variable in the OrderBasketSearchResults component that tracks whether the search input was cleared and set to false and create function onClick handler's logic so that it sets the value of the state variable i created above to true. and i added useEffect hook in OrderBasketSearchResults component that traps focus to the Search input if the boolean state variable is true. After trapping focus, it set the state variable back to false.
244932896-ad73d280-6a3c-4767-9e6c-1e05f57c6ee6.mp4
https://issues.openmrs.org/browse/O3-2158