diff --git a/app/assets/javascripts/components/AutocompleteTagInput.tsx b/app/assets/javascripts/components/AutocompleteTagInput.tsx index e3771024d..80c865f39 100644 --- a/app/assets/javascripts/components/AutocompleteTagInput.tsx +++ b/app/assets/javascripts/components/AutocompleteTagInput.tsx @@ -25,10 +25,10 @@ export const AutocompleteTagInput = observer(({ appState }: Props) => { const [dropdownMaxHeight, setDropdownMaxHeight] = useState('auto'); - const dropdownRef = useRef(); + const containerRef = useRef(); const inputRef = useRef(); - const [closeOnBlur] = useCloseOnBlur(dropdownRef, (visible: boolean) => { + const [closeOnBlur] = useCloseOnBlur(containerRef, (visible: boolean) => { setDropdownVisible(visible); appState.noteTags.clearAutocompleteSearch(); }); @@ -69,7 +69,9 @@ export const AutocompleteTagInput = observer(({ appState }: Props) => { case 'ArrowDown': event.preventDefault(); if (autocompleteTagResults.length > 0) { - appState.noteTags.setFocusedTagResultUuid(autocompleteTagResults[0].uuid); + appState.noteTags.setFocusedTagResultUuid( + autocompleteTagResults[0].uuid + ); } else if (autocompleteTagHintVisible) { appState.noteTags.setAutocompleteTagHintFocused(true); } @@ -96,50 +98,60 @@ export const AutocompleteTagInput = observer(({ appState }: Props) => { }, [appState.noteTags, autocompleteInputFocused]); return ( -
0 ? 'mt-2' : ''}`} - > - - 0 ? 'w-80' : 'w-70 mr-10'} bg-transparent text-xs +
+ 0 ? 'mt-2' : ''}`} + > + + 0 ? 'w-80' : 'w-70 mr-10' + } bg-transparent text-xs color-text no-border h-7 focus:outline-none focus:shadow-none focus:border-bottom`} - value={autocompleteSearchQuery} - onChange={onSearchQueryChange} - type="text" - placeholder="Add tag" - onBlur={onBlur} - onFocus={onFocus} - onKeyDown={onKeyDown} - tabIndex={tags.length === 0 ? 0 : -1} - /> - {dropdownVisible && (autocompleteTagResults.length > 0 || autocompleteTagHintVisible) && ( - 0 ? 'w-80' : 'w-70 mr-10'} sn-dropdown flex flex-col py-2 absolute`} - style={{ maxHeight: dropdownMaxHeight, maxWidth: tagsContainerMaxWidth }} - onBlur={closeOnBlur} - > -
- {autocompleteTagResults.map((tagResult: SNTag) => ( - - ))} -
- {autocompleteTagHintVisible && ( - + value={autocompleteSearchQuery} + onChange={onSearchQueryChange} + type="text" + placeholder="Add tag" + onBlur={onBlur} + onFocus={onFocus} + onKeyDown={onKeyDown} + tabIndex={tags.length === 0 ? 0 : -1} + /> + {dropdownVisible && + (autocompleteTagResults.length > 0 || + autocompleteTagHintVisible) && ( + 0 ? 'w-80' : 'w-70 mr-10' + } sn-dropdown flex flex-col py-2 absolute`} + style={{ + maxHeight: dropdownMaxHeight, + maxWidth: tagsContainerMaxWidth, + }} + onBlur={closeOnBlur} + > +
+ {autocompleteTagResults.map((tagResult: SNTag) => ( + + ))} +
+ {autocompleteTagHintVisible && ( + + )} +
)} -
- )} -
- + + +
); });