@@ -146,6 +146,7 @@ function renderBytes(
146146 virtualListStore ?: VirtualListStateStore ;
147147 tableStore ?: TableStateStore ;
148148 treeStore ?: TreeStateStore ;
149+ focusedId ?: string | null ;
149150 } > ,
150151) : Uint8Array {
151152 const allocator = createInstanceIdAllocator ( 1 ) ;
@@ -169,7 +170,7 @@ function renderBytes(
169170 tree : committed . value . root ,
170171 layout : layoutRes . value ,
171172 viewport,
172- focusState : Object . freeze ( { focusedId : null } ) ,
173+ focusState : Object . freeze ( { focusedId : stores ?. focusedId ?? null } ) ,
173174 builder,
174175 virtualListStore : stores ?. virtualListStore ,
175176 tableStore : stores ?. tableStore ,
@@ -183,6 +184,7 @@ function renderBytes(
183184
184185describe ( "renderer regressions" , ( ) => {
185186 const noop = ( ..._args : readonly unknown [ ] ) => undefined ;
187+ const ATTR_INVERSE = 1 << 3 ;
186188
187189 test ( "box shadow renders shade glyphs when enabled" , ( ) => {
188190 const withShadow = parseInternedStrings (
@@ -252,6 +254,58 @@ describe("renderer regressions", () => {
252254 assert . equal ( withFillCount > withoutFillCount , true ) ;
253255 } ) ;
254256
257+ test ( "table single-selection suppresses focused inverse style when focused row is not selected" , ( ) => {
258+ const tableStore = createTableStateStore ( ) ;
259+ tableStore . set ( "tbl-single-active" , { focusedRowIndex : 1 } ) ;
260+
261+ const bytes = renderBytes (
262+ ui . table ( {
263+ id : "tbl-single-active" ,
264+ columns : [ { key : "name" , header : "Name" , width : 10 } ] ,
265+ data : [
266+ { id : "r0" , name : "A" } ,
267+ { id : "r1" , name : "B" } ,
268+ ] ,
269+ getRowKey : ( row ) => row . id ,
270+ selectionMode : "single" ,
271+ selection : [ "r0" ] ,
272+ border : "none" ,
273+ } ) ,
274+ { cols : 40 , rows : 8 } ,
275+ { tableStore, focusedId : "tbl-single-active" } ,
276+ ) ;
277+
278+ const styles = parseCommandStyles ( bytes ) ;
279+ const hasInverse = styles . some ( ( s ) => ( s . attrs & ATTR_INVERSE ) !== 0 ) ;
280+ assert . equal ( hasInverse , false ) ;
281+ } ) ;
282+
283+ test ( "table keeps focused inverse style when focused row is selected" , ( ) => {
284+ const tableStore = createTableStateStore ( ) ;
285+ tableStore . set ( "tbl-single-active-selected" , { focusedRowIndex : 1 } ) ;
286+
287+ const bytes = renderBytes (
288+ ui . table ( {
289+ id : "tbl-single-active-selected" ,
290+ columns : [ { key : "name" , header : "Name" , width : 10 } ] ,
291+ data : [
292+ { id : "r0" , name : "A" } ,
293+ { id : "r1" , name : "B" } ,
294+ ] ,
295+ getRowKey : ( row ) => row . id ,
296+ selectionMode : "single" ,
297+ selection : [ "r1" ] ,
298+ border : "none" ,
299+ } ) ,
300+ { cols : 40 , rows : 8 } ,
301+ { tableStore, focusedId : "tbl-single-active-selected" } ,
302+ ) ;
303+
304+ const styles = parseCommandStyles ( bytes ) ;
305+ const hasInverse = styles . some ( ( s ) => ( s . attrs & ATTR_INVERSE ) !== 0 ) ;
306+ assert . equal ( hasInverse , true ) ;
307+ } ) ;
308+
255309 test ( "table column overflow policies render ellipsis, middle, and clip deterministically" , ( ) => {
256310 const strings = parseInternedStrings (
257311 renderBytes (
0 commit comments