pr feedback

This commit is contained in:
martabal 2023-12-05 02:06:00 +01:00
parent 58b6968a12
commit 06a2fcb246
No known key found for this signature in database
GPG key ID: C00196E3148A52BD
2 changed files with 11 additions and 8 deletions

View file

@ -26,7 +26,11 @@
export let fullwidth = false; export let fullwidth = false;
export let border = false; export let border = false;
export let title: string | undefined = ''; export let title: string | undefined = '';
export let ref: HTMLButtonElement | null = null; export const focus = () => {
ref.focus;
};
let ref: HTMLButtonElement;
const colorClasses: Record<Color, string> = { const colorClasses: Record<Color, string> = {
primary: primary:

View file

@ -17,8 +17,8 @@
let { isViewing: showAssetViewer } = assetViewingStore; let { isViewing: showAssetViewer } = assetViewingStore;
let choosePersonToMerge = false; let choosePersonToMerge = false;
let changeFocus = false; let changeFocus = false;
let buttonNo: HTMLButtonElement; let focusButtonNo: () => void;
let buttonYes: HTMLButtonElement; let focusButtonYes: () => void;
const title = personMerge2.name; const title = personMerge2.name;
@ -30,15 +30,14 @@
const handleKeyboardPress = (event: KeyboardEvent) => { const handleKeyboardPress = (event: KeyboardEvent) => {
if (!$showAssetViewer) { if (!$showAssetViewer) {
event.stopPropagation();
switch (event.key) { switch (event.key) {
case 'Tab': case 'Tab':
event.preventDefault(); event.preventDefault();
if (changeFocus) { if (changeFocus) {
buttonYes.focus(); focusButtonYes();
} else { } else {
buttonNo.focus(); focusButtonNo();
} }
changeFocus = !changeFocus; changeFocus = !changeFocus;
@ -144,8 +143,8 @@
<p class="text-sm text-gray-500 dark:text-gray-300">They will be merged together</p> <p class="text-sm text-gray-500 dark:text-gray-300">They will be merged together</p>
</div> </div>
<div class="mt-8 flex w-full gap-4 px-4 pb-4"> <div class="mt-8 flex w-full gap-4 px-4 pb-4">
<Button bind:ref={buttonNo} color="gray" fullwidth on:click={() => dispatch('reject')}>No</Button> <Button bind:focus={focusButtonNo} color="gray" fullwidth on:click={() => dispatch('reject')}>No</Button>
<Button bind:ref={buttonYes} fullwidth on:click={() => dispatch('confirm', [personMerge1, personMerge2])} <Button bind:focus={focusButtonYes} fullwidth on:click={() => dispatch('confirm', [personMerge1, personMerge2])}
>Yes</Button >Yes</Button
> >
</div> </div>