Skip to content

Commit

Permalink
Update boolean logic to ensure suggestions list closes when expandOnF…
Browse files Browse the repository at this point in the history
…ocus prop is false
  • Loading branch information
talldan committed Dec 12, 2023
1 parent 65486ec commit 9de4de7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/components/src/form-token-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ export function FormTokenField( props: FormTokenFieldProps ) {
setInputOffsetFromEnd( 0 );
setIsActive( false );

// If `__experimentalExpandOnFocus` is true, don't close the suggestions list when
// the user clicks on it (`tokensAndInput` will be the element that caused the blur).
const shouldKeepSuggestionsExpanded =
! __experimentalExpandOnFocus ||
( __experimentalExpandOnFocus &&
event.relatedTarget === tokensAndInput.current );
setIsExpanded( shouldKeepSuggestionsExpanded );
if ( __experimentalExpandOnFocus ) {
// If `__experimentalExpandOnFocus` is true, don't close the suggestions list when
// the user clicks on it (`tokensAndInput` will be the element that caused the blur).
setIsExpanded( event.relatedTarget === tokensAndInput.current );
} else {
setIsExpanded( false );
}

setSelectedSuggestionIndex( -1 );
setSelectedSuggestionScroll( false );
Expand Down

0 comments on commit 9de4de7

Please sign in to comment.