Select an item's value when its cell is clicked for editing
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

Clicking a cell in the Items table now focuses that field's input and selects
its contents, so the user can type a replacement value immediately. FieldCell
gains an `autoFocus` prop (focus + select on mount via a merged ref that still
supports the draft row's first-field ref); InventoryTable tracks which cell was
clicked and flags the matching FieldCell.

Also add a FieldSchemaEditor test covering the select-options comma fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-06-19 13:47:32 -06:00
parent 6dd8e43635
commit 447e4a40df
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
4 changed files with 102 additions and 8 deletions

View file

@ -0,0 +1,35 @@
import React from "react";
import {fireEvent, render, screen} from "@testing-library/react";
import {FieldSchemaEditor} from "./FieldSchemaEditor";
const FIELDS = [
{key: 'name', label: 'Name', type: 'text', order: 0},
{key: 'category', label: 'Category', type: 'select', options: [], order: 1},
];
describe('FieldSchemaEditor select options', () => {
test('typing a comma is preserved while editing (does not get swallowed)', () => {
render(<FieldSchemaEditor fields={FIELDS} open={true} onClose={jest.fn()} onSave={jest.fn()}/>);
const optionsInput = screen.getByPlaceholderText('comma,separated,options');
// Typing the comma after the first option must not be stripped — otherwise a second option can't be started.
fireEvent.change(optionsInput, {target: {value: 'screws,'}});
expect(optionsInput.value).toBe('screws,');
fireEvent.change(optionsInput, {target: {value: 'screws,nails'}});
expect(optionsInput.value).toBe('screws,nails');
});
test('options are trimmed and emptied-out on save', async () => {
const onSave = jest.fn();
render(<FieldSchemaEditor fields={FIELDS} open={true} onClose={jest.fn()} onSave={onSave}/>);
const optionsInput = screen.getByPlaceholderText('comma,separated,options');
fireEvent.change(optionsInput, {target: {value: 'screws, nails ,'}});
fireEvent.click(screen.getByText('Save Fields'));
const savedFields = onSave.mock.calls[0][0];
const category = savedFields.find(f => f.key === 'category');
expect(category.options).toEqual(['screws', 'nails']);
});
});