Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): merge suggestion modal: focus on Yes button by default. #15827

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions web/src/lib/components/elements/buttons/button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,19 @@
.filter(Boolean)
.join(' '),
);

let linkOrButton: HTMLAnchorElement | HTMLButtonElement | null = null;

export function focus() {
linkOrButton?.focus();
}
</script>

<!-- svelte-ignore a11y_no_static_element_interactions -->
<svelte:element
this={href ? 'a' : 'button'}
type={href ? undefined : type}
bind:this={linkOrButton}
{href}
{onclick}
{onfocus}
Expand Down
12 changes: 11 additions & 1 deletion web/src/lib/components/faces-page/merge-suggestion-modal.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { onMount, tick } from 'svelte';
import Icon from '$lib/components/elements/icon.svelte';
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
import { getPeopleThumbnailUrl } from '$lib/utils';
Expand Down Expand Up @@ -36,6 +37,13 @@
[potentialMergePeople[index], personMerge2] = [personMerge2, potentialMergePeople[index]];
choosePersonToMerge = false;
};

let confirmButtonRef: Button | null = null;

onMount(async () => {
await tick();
confirmButtonRef?.focus();
});
</script>

<FullScreenModal title="{$t('merge_people')} - {title}" {onClose}>
Expand Down Expand Up @@ -114,6 +122,8 @@

{#snippet stickyBottom()}
<Button fullwidth color="gray" onclick={onReject}>{$t('no')}</Button>
<Button fullwidth onclick={() => onConfirm([personMerge1, personMerge2])}>{$t('yes')}</Button>
<Button fullwidth bind:this={confirmButtonRef} onclick={() => onConfirm([personMerge1, personMerge2])}>
{$t('yes')}
</Button>
{/snippet}
</FullScreenModal>
Loading