Open archiecobbs opened 7 months ago
This is a side effect from the fact that Column
extends Component
and we have opted to make Component
implement HasStyle
since 99% of all components do support styles in a sensible way. Column
is one of the exceptions. To apply styles to the cells in a column, you can use Column::setClassNameGenerator
or Column::setPartNameGenerator
in cases when the styles can be defined in a CSS file. For other cases, you would have to define a custom renderer.
I can see multiple alternatives for addressing this issue, but they all have tradeoffs:
getStyle()
method in Column
only to mark it as deprecated. Easy but limited.Column
to not be a Component
. Relatively big effort and probably a breaking change in some cases.HasStyle
from Component
. Semantically correct but big breaking change.I can see multiple alternatives for addressing this issue, but they all have tradeoffs:
My vote is for #1. My reasoning is that it's likely that very few people are currently using Grid.Column.getStyle()
because it doesn't do anything. So the change should be 99% backward compatible. Moreover adding this support imposes no cost to anyone who doesn't use it (or for any columns that don't have their style modified), so we're not breaking anything that already exists.
Not sure what "surprises" one might find other than something that didn't work before suddenly starts working :)
My second choice would be to vote for adding documentation to the Grid.Column
API Javadoc explaining that the HasStyle
methods don't work for the class, so other people don't waste their time falling into this same trap.
Thanks.
Description
I have a
Grid.Column
and I saygetStyle().set("font", "Courier")
but it doesn't change the font of what's displayed.Expected outcome
Fixed-width font for my column data.
Minimal reproducible example
I'm not a CSS or shadow DOM expert. But what I see is:
Doing this:
column.getStyle().set("font", "Courier")
Results in this:
Steps to reproduce
column.getStyle().set("font", "Courier")
Grid
Environment
Vaadin version(s): 24.3.5 OS: Mac OS
Browsers
Firefox