They will be merged together
-
+
diff --git a/web/src/routes/(user)/people/[personId]/+page.svelte b/web/src/routes/(user)/people/[personId]/+page.svelte
index 3d96387659..c6cac370c7 100644
--- a/web/src/routes/(user)/people/[personId]/+page.svelte
+++ b/web/src/routes/(user)/people/[personId]/+page.svelte
@@ -88,6 +88,8 @@
**/
let searchWord: string;
let isSearchingPeople = false;
+ let focusedElements: (HTMLButtonElement | null)[] = Array.from({ length: maximumLengthSearchPeople }, () => null);
+ let indexFocus: number | null = null;
const searchPeople = async () => {
if ((people.length < maximumLengthSearchPeople && name.startsWith(searchWord)) || name === '') {
@@ -116,6 +118,7 @@
$: {
if (people) {
suggestedPeople = name ? searchNameLocal(name, people, 5, data.person.id) : [];
+ indexFocus = null;
}
}
@@ -129,8 +132,51 @@
viewMode = ViewMode.MERGE_PEOPLE;
}
});
+
+ const handleKeyboardPress = (event: KeyboardEvent) => {
+ if (suggestedPeople.length === 0) {
+ return;
+ }
+ if (!$showAssetViewer) {
+ event.stopPropagation();
+ switch (event.key) {
+ case 'ArrowDown': {
+ event.preventDefault();
+ if (indexFocus === null) {
+ indexFocus = 0;
+ } else if (indexFocus === suggestedPeople.length - 1) {
+ indexFocus = 0;
+ } else {
+ indexFocus++;
+ }
+ focusedElements[indexFocus]?.focus();
+ return;
+ }
+ case 'ArrowUp': {
+ if (indexFocus === null) {
+ indexFocus = 0;
+ return;
+ }
+ if (indexFocus === 0) {
+ indexFocus = suggestedPeople.length - 1;
+ } else {
+ indexFocus--;
+ }
+ focusedElements[indexFocus]?.focus();
+
+ return;
+ }
+ case 'Enter': {
+ if (indexFocus !== null) {
+ handleSuggestPeople(suggestedPeople[indexFocus]);
+ }
+ }
+ }
+ }
+ };
+
const handleEscape = () => {
- if ($showAssetViewer) {
+ if ($showAssetViewer || viewMode === ViewMode.SUGGEST_MERGE) {
return;
}
if ($isMultiSelectState) {
@@ -350,6 +396,7 @@
};
+