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

View File

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