Keep the keyboard on the grid after the formula bar; editor uses cell colours

- Enter/Escape in the formula bar (and a jump via the Name Box) hand the
  focus back to the table of the selection, so the arrow keys move the
  active cell again instead of doing nothing.
- The in-cell editor takes the cell's own text/fill colour and bold/
  italic, so a light-on-dark cell no longer turns into dark text on a
  dark fill while editing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
wkh
2026-09-28 20:50:16 +02:00
co-authored by Claude Opus 5.5
parent 7fce972fdc
commit 5871524421
2 changed files with 29 additions and 4 deletions
+17 -1
View File
@@ -878,12 +878,21 @@ let committing = false;
const editStyle = computed(() => {
const s = editing.value;
if (!s) return {};
return {
// look like the cell being edited: its own text/fill colour (else the
// table's), bold/italic -- a white-on-dark cell must not turn into dark
// text on a dark fill while editing
const f = store.cellFormat(props.tableId, s.col, s.row);
const style: Record<string, string> = {
left: colLeft(s.col) + 'px',
top: rowTop(s.row) + 'px',
minWidth: colWidth(s.col) + 'px',
minHeight: rowH(s.row) + 'px',
};
if (f.color) style['--text'] = f.color;
if (f.bg) style['--surface'] = f.bg;
if (f.bold) style.fontWeight = '600';
if (f.italic) style.fontStyle = 'italic';
return style;
});
const editMirrorStyle = computed(() => {
const s = editing.value;
@@ -1332,7 +1341,14 @@ const totalWidth = computed(() => {
return w;
});
// the formula bar / Name Box hand the keyboard back after Enter/Escape
function onFocusGridRequest(e: Event) {
if ((e as CustomEvent<string>).detail === props.tableId) root.value?.focus();
}
window.addEventListener('numolus:focus-grid', onFocusGridRequest);
onBeforeUnmount(() => {
window.removeEventListener('numolus:focus-grid', onFocusGridRequest);
onDragUp();
onPointDragUp();
onFillDragUp();