@@ -24,7 +24,7 @@ import type {
2424 Schema ,
2525} from "../types.js" ;
2626import type { CellScalar , DataResponse } from "regular-table/dist/esm/types.js" ;
27- import { ViewWindow } from "@perspective-dev/client" ;
27+ import { ViewConfig , ViewWindow } from "@perspective-dev/client" ;
2828
2929interface ColumnData {
3030 __ROW_PATH__ ?: unknown [ ] [ ] ;
@@ -192,8 +192,10 @@ export function createDataListener(
192192 column_paths . push ( path ) ;
193193 }
194194
195+ const is_dim_call = x1 - x0 > 0 && y1 - y0 > 0 ;
196+
195197 // Only update the last state if this is not a "phantom" call.
196- if ( x1 - x0 > 0 && y1 - y0 > 0 ) {
198+ if ( is_dim_call ) {
197199 this . last_column_paths = last_column_paths ;
198200 this . last_meta = last_meta ;
199201 this . last_ids = last_ids ;
@@ -223,7 +225,9 @@ export function createDataListener(
223225 ) ,
224226 ) as ( string | HTMLElement ) [ ] [ ] ;
225227
226- const num_row_headers = row_headers [ 0 ] ?. length ;
228+ const num_row_headers = ! is_dim_call
229+ ? row_header_depth ( this . _config )
230+ : row_headers [ 0 ] ?. length ;
227231
228232 const result : DataResponse = {
229233 num_column_headers :
@@ -244,3 +248,15 @@ export function createDataListener(
244248 return result ;
245249 } ;
246250}
251+
252+ function row_header_depth ( config : ViewConfig ) {
253+ if ( config . group_rollup_mode === "flat" ) {
254+ return config . group_by . length ;
255+ } else if ( config . group_rollup_mode === "total" ) {
256+ return 0 ;
257+ } else if ( config . group_by . length === 0 ) {
258+ return 0 ;
259+ } else {
260+ return config . group_by . length + 1 ;
261+ }
262+ }
0 commit comments