Repository navigation
Conversation
Apps that paint their own row state still inherited table_hover on pointer hover. row_hover(false) skips that fill while leaving selection and the right-click outline in place. Co-authored-by: Cursor <cursoragent@cursor.com>
huacnlee
left a comment
There was a problem hiding this comment.
The requirement is reasonable: applications should be able to preserve their own row-state styling without the default hover background overriding it.
However, I do not think row_hover is a good public API design. It adds a switch for one specific styling conflict rather than providing a systematic approach to row styling.
Please address this through the existing TableDelegate::render_tr customization point. Default row and hover styles should provide a fallback, while application-provided styles can override them. Selection and right-click presentation should retain explicitly defined precedence.
The current implementation unconditionally applies .hover(...) after render_tr, so the extension point cannot currently fulfill that contract. Please resolve that style-composition limitation rather than introducing row_hover. This needs to account for GPUI’s hover-style API; calling .hover(...) twice is not a safe composition strategy.
|
To make the requested direction concrete, here is the intended usage inside an application's fn render_tr(
&mut self,
row_ix: usize,
_window: &mut Window,
cx: &mut Context<TableState<Self>>,
) -> Stateful<Div> {
// Illustrative application-owned row-state color, resolved from the theme.
let background = cx.theme().tokens.table_even;
div()
.id(("row", row_ix))
.bg(background)
.hover(move |style| style.bg(background))
}Here the application explicitly keeps its row-state background on hover. It could equally supply a different hover background or additional hover styling through the same extension point. A delegate that does not specify hover styling should keep DataTable's default This is the intended usage after fixing style composition, not a workaround that works with the current implementation: DataTable currently calls |
Description
DataTablealways paintedtable_hoveron a hovered row, so a table that already shows its own row state still picked up that fill.row_hover(false)skips it. The default staystrue, so existing tables look the same.Selected-row background and the right-click outline stay either way. Header and sort-icon hover are unchanged. The hover callback is still registered when the fill is off, so a row that is already under the pointer drops the background on the next frame instead of keeping it until the pointer leaves.
Screenshot
No visual change when
row_hoveris left at its default. The Data Table story adds a Row Hover menu item, checked by default, to turn the fill off.Public API
gpui-component
gpui_component::table::DataTable::row_hover(self, row_hover: bool) -> Self— whenfalse, a hovered row does not paint thetable_hoverbackground. Default istrue. Selected-row background and the right-click outline stay either way.How to Test
cargo check -p gpui-component -p gpui-component-story(passed here)cargo runand open the Data Table story. With Row Hover checked, rows still paint the hover background. Uncheck it and hovered rows no longer paint that fill.row_hoverkeeps the previous hover background.Checklist
cargo runfor story tests related to the changes.Made with Cursor