Skip to content

Commit

Permalink
feat(dropdown.tsx): made logical statement shorter, reverified blur f…
Browse files Browse the repository at this point in the history
…ucntionliaty

when swapping between the 8 combinations of searchable,placeholder,multi

feat #449
  • Loading branch information
j-leidy committed Jul 18, 2023
1 parent b114578 commit 5abcf09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,12 @@ const Dropdown = ({
// when searchable, only blur if the event is from the input
setFocusTimeoutId(
window.setTimeout(() => {
const blurredFromButtom = !searchable && e.target.id === `${name}-dropdown-button`;
const blurredFromSearch = searchable && e.target.id === `${name}-search-input`;
if (
focusWithin &&
((!searchable && e.target.id === `${name}-dropdown-button`) ||
(searchable && e.target.id === `${name}-search-input`))
(blurredFromButtom ||
blurredFromSearch)
) {
setFocusWithin(false);
setIsOpen(false);
Expand Down Expand Up @@ -682,7 +684,6 @@ const Dropdown = ({
(clickedId: string | number) => {
if (!multi) {
setIsOpen(false);
// not sure how i feel about this... the focus currently stays after selecting an item when multi is false
setFocusWithin(false);
handleOnSelect([clickedId]);
} else {
Expand Down

0 comments on commit 5abcf09

Please sign in to comment.