1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-10 23:22:22 +02:00

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
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>