Skip to content

Commit f68b254

Browse files
YidaWenghuacnlee
andauthored
table: Cover DataTable builder and focus ring configuration (#3572)
## Description The DataTable `FocusableExt` implementation requested by #3538 already landed in #3565. This PR now supplements that implementation with the missing DataTable builder test. The branch merges current main, retaining its focus-ring implementation and keyboard-focus interaction tests. The new test checks the default focus-ring setting, disabling and re-enabling it on the same configured table, and composition with the other table builders. ## Public API No additional public API changes relative to main. `impl<D: TableDelegate> FocusableExt for DataTable<D>` is already available through #3565. ## Validation - `cargo test -p gpui-component --lib --features test-support table:: --locked`: 6 passed. - `cargo clippy -p gpui-component --lib --tests --features test-support --locked -- --deny warnings`: passed. - `cargo fmt -p gpui-component -- --check`: passed. - No manual story-gallery verification; this PR adds test coverage only. AI assistance: the original change was AI-assisted. Codex resolved the merge conflict, adapted the builder test to main, and ran the checks above. Co-authored-by: Jason Lee <huacnlee@gmail.com>
1 parent e971783 commit f68b254

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎crates/component/src/table/data_table.rs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,37 @@ mod tests {
304304
cx
305305
}
306306

307+
#[gpui::test]
308+
fn test_data_table_builder(cx: &mut TestAppContext) {
309+
cx.update(crate::init);
310+
let (view, cx) = cx.add_window_view(|window, cx| FocusRingHarness {
311+
state: cx.new(|cx| TableState::new(RowsDelegate, window, cx)),
312+
focus_ring: true,
313+
});
314+
let state = view.read_with(cx, |view, _| view.state.clone());
315+
assert!(DataTable::new(&state).is_focus_ring_enabled());
316+
317+
let table = DataTable::new(&state)
318+
.stripe(true)
319+
.bordered(false)
320+
.scroll_bounce(false)
321+
.header_row_height(px(32.))
322+
.fixed_cols_border(false)
323+
.scrollbar_visible(false, true)
324+
.with_size(Size::Small)
325+
.focus_ring(false);
326+
assert!(table.options.stripe);
327+
assert!(!table.options.bordered);
328+
assert_eq!(table.options.scroll_bounce, Some(false));
329+
assert_eq!(table.options.header_row_height, Some(px(32.)));
330+
assert!(!table.options.fixed_cols_border);
331+
assert!(!table.options.scrollbar_visible.right);
332+
assert!(table.options.scrollbar_visible.bottom);
333+
assert_eq!(table.options.size, Size::Small);
334+
assert!(!table.is_focus_ring_enabled());
335+
assert!(table.focus_ring(true).is_focus_ring_enabled());
336+
}
337+
307338
#[gpui::test]
308339
fn data_table_draws_the_focus_ring_by_default(cx: &mut TestAppContext) {
309340
let cx = keyboard_focused_table(cx, true);

0 commit comments

Comments
 (0)