@@ -95,6 +95,7 @@ export class RegularVirtualTableViewModel extends HTMLElement {
9595 protected _is_styling ?: boolean ;
9696 protected table_model ! : RegularTableViewModel ;
9797 protected _style_callbacks ! : Array < StyleCallback > ;
98+ private _probe_element ?: [ HTMLElement , HTMLElement ] ;
9899
99100 /**
100101 * Draws this virtual panel, given an object of render options that allow
@@ -123,6 +124,30 @@ export class RegularVirtualTableViewModel extends HTMLElement {
123124 await flush_tag ( this ) ;
124125 }
125126
127+ /**
128+ * Probe the shadow DOM to measure the default row height from CSS.
129+ */
130+ protected _probe_row_height ( ) {
131+ if ( ! this . _probe_element ) {
132+ this . _probe_element = [
133+ document . createElement ( "table" ) ,
134+ document . createElement ( "td" ) ,
135+ ] ;
136+ this . _probe_element [ 0 ] . style . visibility = "hidden" ;
137+ this . _probe_element [ 0 ] . style . position = "absolute" ;
138+ const tbody = document . createElement ( "tbody" ) ;
139+ const tr = document . createElement ( "tr" ) ;
140+ this . _probe_element [ 1 ] . textContent = "X" ;
141+ tr . appendChild ( this . _probe_element [ 1 ] ) ;
142+ tbody . appendChild ( tr ) ;
143+ this . _probe_element [ 0 ] . appendChild ( tbody ) ;
144+ }
145+
146+ this . appendChild ( this . _probe_element [ 0 ] ) ;
147+ this . _column_sizes . row_height = this . _probe_element [ 1 ] . offsetHeight ;
148+ this . _probe_element [ 0 ] . remove ( ) ;
149+ }
150+
126151 /**
127152 * Create the DOM for this `shadowRoot`.
128153 */
@@ -243,11 +268,13 @@ export class RegularVirtualTableViewModel extends HTMLElement {
243268 for ( const w of this . _column_sizes . indices ) {
244269 totalWidth += w || 0 ;
245270 }
271+
246272 this . _virtual_panel . style . width =
247273 totalWidth . toPrecision ( 10 ) + "px" ;
248274 } else {
249275 const virtual_width =
250276 this . _calc_scrollable_column_width ( num_columns ) ;
277+
251278 if ( virtual_width !== 0 ) {
252279 const panel_width =
253280 this . _container_size . width + virtual_width + 2 ;
@@ -266,7 +293,7 @@ export class RegularVirtualTableViewModel extends HTMLElement {
266293 * @param {* } nrows
267294 */
268295 protected _update_virtual_panel_height ( nrows : number ) : void {
269- const { row_height = 19 } = this . _column_sizes ;
296+ const { row_height = 0 } = this . _column_sizes ;
270297 const header_height =
271298 this . _view_cache . column_headers_length * row_height ;
272299 let virtual_panel_px_size ;
@@ -287,7 +314,7 @@ export class RegularVirtualTableViewModel extends HTMLElement {
287314 last_cell ?: CellTuple ,
288315 ) : void {
289316 const y_offset =
290- ( this . _column_sizes . row_height || 20 ) * ( viewport . start_row % 1 ) ||
317+ ( this . _column_sizes . row_height || 0 ) * ( viewport . start_row % 1 ) ||
291318 0 ;
292319
293320 const x_offset_index =
@@ -379,7 +406,7 @@ export class RegularVirtualTableViewModel extends HTMLElement {
379406 end_row : number ;
380407 } {
381408 const { height, containerHeight } = this . _container_size ;
382- const row_height = this . _column_sizes . row_height || 19 ;
409+ const row_height = this . _column_sizes . row_height || 0 ;
383410 const header_levels = this . _view_cache . column_headers_length ;
384411 const total_scroll_height = Math . max (
385412 1 ,
@@ -521,6 +548,10 @@ async function internal_draw(
521548 } = await this . table_model . _getDimState ( this . _view_cache ) ;
522549
523550 this . _column_sizes . row_height = row_height || this . _column_sizes . row_height ;
551+ if ( ! this . _column_sizes . row_height ) {
552+ this . _probe_row_height ( ) ;
553+ }
554+
524555 if ( num_row_headers !== undefined ) {
525556 this . _view_cache . row_headers_length = num_row_headers ;
526557 }
0 commit comments