mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04: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:
parent
de2115d11e
commit
526206b2a5
@ -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' },
|
||||||
|
@ -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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user