feat(web): Focus on combo box input when opening add tag modal (#18923)

- Add forceFocus prop to ComboBox (optional, false)
- Set forceFocus on AssetTagModal combobox
This commit is contained in:
xCJPECKOVERx 2025-06-08 22:36:34 -04:00 committed by GitHub
parent de2115d11e
commit 526206b2a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -46,6 +46,7 @@
*/ */
defaultFirstOption?: boolean; defaultFirstOption?: boolean;
onSelect?: (option: ComboBoxOption | undefined) => void; onSelect?: (option: ComboBoxOption | undefined) => void;
forceFocus?: boolean;
} }
let { let {
@ -57,6 +58,7 @@
allowCreate = false, allowCreate = false,
defaultFirstOption = false, defaultFirstOption = false,
onSelect = () => {}, onSelect = () => {},
forceFocus = false,
}: Props = $props(); }: Props = $props();
/** /**
@ -115,6 +117,12 @@
}; };
}); });
const forceFocusInput = (el: HTMLDivElement) => {
if (forceFocus) {
el.focus();
}
};
const activate = () => { const activate = () => {
isActive = true; isActive = true;
searchQuery = ''; searchQuery = '';
@ -284,6 +292,7 @@
role="combobox" role="combobox"
type="text" type="text"
value={searchQuery} value={searchQuery}
use:forceFocusInput
use:shortcuts={[ use:shortcuts={[
{ {
shortcut: { key: 'ArrowUp' }, shortcut: { key: 'ArrowUp' },

View File

@ -66,6 +66,7 @@
defaultFirstOption defaultFirstOption
options={allTags.map((tag) => ({ id: tag.id, label: tag.value, value: tag.id }))} options={allTags.map((tag) => ({ id: tag.id, label: tag.value, value: tag.id }))}
placeholder={$t('search_tags')} placeholder={$t('search_tags')}
forceFocus
/> />
</div> </div>
</form> </form>