@@ -376,6 +376,9 @@ const TABLE_DEFAULT_TRANSLATIONS: Record<string, string> = {
376376 'table.cellSaved' : 'Saved' ,
377377 // objectstack#35689 — what the table's live region says when cells saved.
378378 'table.cellSavedAnnouncement' : 'Saved: {{fields}}' ,
379+ // The pack's list punctuation the announcement joins column names with
380+ // (`、` in ja and zh), the key the form's field lists use.
381+ 'validation.formInvalidJoiner' : ', ' ,
379382 'table.openRecordToFinish' : 'Open the record to finish this change' ,
380383 'common.actions' : 'Actions' ,
381384 // objectui#10625 — the inline date editors' notice for a stored value
@@ -1491,9 +1494,10 @@ function CellEditButton({
14911494 editableRef . current = editable ;
14921495 const selectedRef = useRef ( selected ) ;
14931496 selectedRef . current = selected ;
1494- // objectstack#35689 — the pointer that pressed the button last. A touch never
1495- // selects the cell, so on a cell not selected the button is never drawn for
1496- // it, and one it lands on anyway (drawn for a mouse before) edits nothing.
1497+ // objectstack#35689 — the pointer that pressed the button for the click that
1498+ // follows, cleared by that click. A touch never selects the cell, so on a
1499+ // cell not selected the button is never drawn for it, and one it lands on
1500+ // anyway (drawn for a mouse before) edits nothing.
14971501 const pressedByRef = useRef ( '' ) ;
14981502 const [ allowed , setAllowed ] = useState ( false ) ;
14991503 useLayoutEffect ( ( ) => {
@@ -1524,9 +1528,14 @@ function CellEditButton({
15241528 onMouseDown = { ( e ) => e . preventDefault ( ) }
15251529 onDoubleClick = { ( e ) => e . stopPropagation ( ) }
15261530 onClick = { ( e ) => {
1527- // objectstack#35689 — a tap on an unselected cell is the row's: it opens
1528- // the record and edits nothing in place, wherever on the cell it lands.
1529- const pointer = ( e . nativeEvent as PointerEvent ) . pointerType || pressedByRef . current ;
1531+ // objectstack#35689 — a tap on an unselected cell edits nothing in
1532+ // place. On the button it does nothing at all: the row's click ignores
1533+ // a click on a button, so the tap opens no record either (a tap beside
1534+ // the button opens it). The press is read once: a later click with no
1535+ // pointer of its own (assistive tech) is not taken for this touch.
1536+ const pressedBy = pressedByRef . current ;
1537+ pressedByRef . current = '' ;
1538+ const pointer = ( e . nativeEvent as PointerEvent ) . pointerType || pressedBy ;
15301539 if ( ! selected && pointer === 'touch' ) return ;
15311540 e . stopPropagation ( ) ;
15321541 onEdit ( ) ;
@@ -3438,11 +3447,16 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
34383447 } ) ;
34393448 setFailureNotice ( ( prev ) => ( prev ?. rowKey === rowKey ? null : prev ) ) ;
34403449 flashSaved ( rowKey , sentKeys ) ;
3441- const fields = sentKeys . map ( ( key ) => {
3450+ // Each saved cell by its column's header, in the locale's list
3451+ // punctuation; a column with no header is never named by its key.
3452+ const fields = sentKeys . flatMap ( ( key ) => {
34423453 const header = columns . find ( ( c ) => c . accessorKey === key ) ?. header ;
3443- return typeof header === 'string' && header !== '' ? header : key ;
3454+ return typeof header === 'string' && header !== '' ? [ header ] : [ ] ;
34443455 } ) ;
3445- setSaveAnnouncement ( ( prev ) => ( { seq : prev . seq + 1 , text : t ( 'table.cellSavedAnnouncement' , { fields : fields . join ( ', ' ) } ) } ) ) ;
3456+ const said = fields . length > 0
3457+ ? t ( 'table.cellSavedAnnouncement' , { fields : fields . join ( t ( 'validation.formInvalidJoiner' ) ) } )
3458+ : t ( 'table.cellSaved' ) ;
3459+ setSaveAnnouncement ( ( prev ) => ( { seq : prev . seq + 1 , text : said } ) ) ;
34463460 } catch ( error ) {
34473461 // The edits stay pending and the cells keep what was typed. Each cell the
34483462 // refusal names shows its own reason; a cell it does not name shows them
@@ -3715,6 +3729,22 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
37153729 const selectedPos = selectedRowIndex >= 0 && selectedColIndex >= 0
37163730 ? { rowIndex : selectedRowIndex , colIndex : selectedColIndex }
37173731 : null ;
3732+ // objectstack#35689 — whether the host holds the selected cell read-only
3733+ // (`GridCellSelection.describeCell`), for its `aria-readonly`. Asked as a
3734+ // cell becomes selected, and again only when what the answer reads changes:
3735+ // the row is re-read, or the host hands the grid a new value (an answer it
3736+ // was waiting on arrived). Never asked per render; every render reads this.
3737+ const selectedRow = selectedPos ? paginatedData [ selectedPos . rowIndex ] : undefined ;
3738+ const selectedColumnKey = selectedPos ? columns [ selectedPos . colIndex ] . accessorKey : undefined ;
3739+ const [ selectedHostReadOnly , setSelectedHostReadOnly ] = useState < { row : any ; columnKey : string } | null > ( null ) ;
3740+ useLayoutEffect ( ( ) => {
3741+ const readOnly = selectedRow !== undefined && selectedColumnKey !== undefined
3742+ && ! ! cellSelection ?. describeCell ?.( selectedRow , selectedColumnKey ) ?. readOnlyReason ;
3743+ setSelectedHostReadOnly ( ( prev ) => {
3744+ if ( ! readOnly ) return null ;
3745+ return prev ?. row === selectedRow && prev . columnKey === selectedColumnKey ? prev : { row : selectedRow , columnKey : selectedColumnKey ! } ;
3746+ } ) ;
3747+ } , [ selectedRow , selectedColumnKey , cellSelection ] ) ;
37183748 const setSelectedCell = ( pos : { rowIndex : number ; colIndex : number } | null ) =>
37193749 setSelectedCellKey ( pos ? { rowKey : pendingRowKeyOf ( paginatedData [ pos . rowIndex ] ) , columnKey : columns [ pos . colIndex ] . accessorKey } : null ) ;
37203750 // objectstack#35688 — a selected cell whose content is cut off shows it in
@@ -5184,11 +5214,12 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
51845214 const isSelectedCell = selectFirst && selectedPos ?. rowIndex === rowIndex && selectedPos . colIndex === colIndex ;
51855215 const showsPreview = isSelectedCell && ! isEditing && previewKey === `${ rowIndex } :${ colIndex } ` ;
51865216 // objectstack#35689 — a read-only cell says so to assistive tech, in the
5187- // grid only. The host 's facts are asked of the selected cell alone (the
5188- // `describeCell` contract: never per render); the cell a reader moves to
5189- // is the selected one, and every other cell reads the table's own facts .
5217+ // grid only, from the table 's own facts. The selected cell (the one a
5218+ // reader moves to) adds the host's, asked when it became selected
5219+ // (`selectedHostReadOnly`: `describeCell` is never asked per render) .
51905220 const cellReadOnly = keyboardNavigation
5191- && ( isSelectedCell ? readOnlyReasonOf ( row , col ) !== null : ! isEditable ) ;
5221+ && ( ! isEditable || ( isSelectedCell && selectedHostReadOnly ?. row === row
5222+ && selectedHostReadOnly . columnKey === col . accessorKey ) ) ;
51925223 // What the cell draws; the preview layer draws the same, unclipped.
51935224 const drawCell = ( ) : React . ReactNode => ( typeof col . cell === 'function'
51945225 ? col . cell ( cellValue , row )
0 commit comments