diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte
index 8eeafff27..07f9bd781 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte
+++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte
@@ -72,9 +72,8 @@
import { chunks } from '$lib/helpers/array';
import { Submit, trackEvent } from '$lib/actions/analytics';
- import IndexesSuggestions from '../(suggestions)/indexes.svelte';
- import { showIndexesSuggestions, tableColumnSuggestions } from '../(suggestions)';
import { isTabletViewport } from '$lib/stores/viewport';
+ import IndexesSuggestions from '../(suggestions)/indexes.svelte';
let editRow: EditRow;
let editRelatedRow: EditRelatedRow;
@@ -87,6 +86,33 @@
let columnCreationHandler: ((response: RealtimeResponse) => void) | null = null;
+ // manual management of focus is needed!
+ const autoFocusAction = (node: HTMLElement, shouldFocus: boolean) => {
+ const button = node.querySelector('button');
+ if (!button) return;
+
+ const handleBlur = () => button.classList.remove('focus-visible');
+ const applyFocus = (focus: boolean) => {
+ if (focus) {
+ button.classList.add('focus-visible');
+ button.focus();
+ } else {
+ button.classList.remove('focus-visible');
+ }
+ };
+
+ button.addEventListener('blur', handleBlur);
+ applyFocus(shouldFocus);
+
+ return {
+ update: applyFocus,
+ destroy() {
+ button.removeEventListener('blur', handleBlur);
+ button.classList.remove('focus-visible');
+ }
+ };
+ };
+
onMount(() => {
expandTabs.set(preferences.getKey('tableHeaderExpanded', true));
@@ -464,39 +490,47 @@
{@const isLastRow = currentIndex >= rows.length - 1}
{#if !$isTabletViewport}
-
+ {@const shouldFocusPrev = !$databaseRowSheetOptions.autoFocus && !isFirstRow}
+ {@const shouldFocusNext =
+ !$databaseRowSheetOptions.autoFocus && isFirstRow && !isLastRow}
-
+
+
+
+
+
+
+
{/if}
{/snippet}
@@ -504,7 +538,8 @@
+ bind:rowId={$databaseRowSheetOptions.rowId}
+ autoFocus={$databaseRowSheetOptions.autoFocus} />
{/key}
@@ -574,3 +609,10 @@
+
+
diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte
index 5b77be33d..afe51be67 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte
+++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/layout/sidesheet.svelte
@@ -92,7 +92,7 @@
{#if topEndActions}
-
+
{@render topEndActions()}
{/if}
diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/edit.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/edit.svelte
index 0754f6420..ab3879962 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/edit.svelte
+++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/edit.svelte
@@ -25,10 +25,12 @@
let {
row = $bindable(),
- rowId = $bindable(null)
+ rowId = $bindable(null),
+ autoFocus = true
}: {
row?: Models.Row | null;
rowId?: string | null;
+ autoFocus?: boolean;
} = $props();
let loading = $state(false);
@@ -82,7 +84,9 @@
$effect(() => {
if (row) {
work = initWork();
- requestAnimationFrame(() => focusFirstInput());
+ if (autoFocus) {
+ requestAnimationFrame(() => focusFirstInput());
+ }
} else {
work = null;
}
diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
index 989d5e653..5e3428bd4 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
+++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
@@ -809,6 +809,7 @@
const focusedRow = $paginatedRows.items.find((row) => row.$id === focusedRowId);
previouslyFocusedElement = document.activeElement;
+ $databaseRowSheetOptions.autoFocus = false;
onSelectSheetOption('update', null, 'row', focusedRow);
}}>
@@ -935,6 +936,7 @@
hide();
previouslyFocusedElement =
document.activeElement;
+ $databaseRowSheetOptions.autoFocus = false;
onSelectSheetOption(
'update',
null,
@@ -985,8 +987,10 @@
- onSelectSheetOption(option, null, 'row', row)}
+ onSelect={(option) => {
+ $databaseRowSheetOptions.autoFocus = true;
+ onSelectSheetOption(option, null, 'row', row);
+ }}
onVisibilityChanged={(visible) => {
canShowDatetimePopover = !visible;
}}>
@@ -1113,6 +1117,7 @@
rowColumn
);
} else {
+ $databaseRowSheetOptions.autoFocus = true;
onSelectSheetOption('update', null, 'row', row);
}
}} />
diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store.ts b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store.ts
index 3f51a93de..6c6a28489 100644
--- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store.ts
+++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store.ts
@@ -72,6 +72,7 @@ export const databaseRowSheetOptions = writable<
rowId?: string;
rows: Models.Row[];
rowIndex?: number;
+ autoFocus?: boolean;
}
>({
title: null,
@@ -79,7 +80,8 @@ export const databaseRowSheetOptions = writable<
row: null,
rowId: null, // for loading from a given id
rows: [],
- rowIndex: -1
+ rowIndex: -1,
+ autoFocus: true
});
export const databaseRelatedRowSheetOptions = writable<