-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fixes table editable cell styles and simplifies it #3061
Conversation
4de7d75
to
0d64af7
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3061 +/- ##
=======================================
Coverage 96.34% 96.35%
=======================================
Files 778 780 +2
Lines 21908 21971 +63
Branches 7507 7472 -35
=======================================
+ Hits 21108 21170 +62
- Misses 748 749 +1
Partials 52 52 ☔ View full report in Codecov by Sentry. |
0d64af7
to
b2a1194
Compare
b2a1194
to
a00bad9
Compare
a8ea9ae
to
82b8f7c
Compare
82b8f7c
to
1492307
Compare
1492307
to
6a78971
Compare
6a78971
to
1845521
Compare
1845521
to
c0e7ae6
Compare
$cell-offset: calc(#{awsui.$space-m} + #{awsui.$space-xs}); | ||
|
||
// Ensuring enough space for absolute-positioned focus outlines of focus-able cell content elements. | ||
$cell-negative-space-vertical: 2px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This negative space was used to virtually enlarge the cell-content element. That is because the element has overflow: hidden
but when there are interactive elements inside such a link or a button dropdown - the focus outline is being cut off.
The negative space is no longer needed because now the cell content size matches cell size. This way the outline can use the available cell space while the content is still truncated correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: the negative space is still needed at least for the compact mode.
align-content: center; | ||
|
||
&.body-cell-align-top { | ||
align-content: baseline; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the cell content takes the entire cell size so the alignment must be attached to it instead of the cell.
align-content: baseline; | ||
} | ||
|
||
&:not(.body-cell-wrap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .body-cell-wrap
only takes effect on the cell-content element so attaching the style to it directly.
// That is to prevent focus outline on cell content from being cut out. | ||
> .body-cell-content { | ||
padding-inline-start: awsui.$border-divider-list-width; | ||
margin-inline-start: calc(-1 * #{awsui.$border-divider-list-width}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This negative space shenanigans are no longer needed because there is plenty of space for the focus outline.
@@ -380,19 +373,6 @@ $cell-negative-space-vertical: 2px; | |||
color: awsui.$color-text-button-normal-active; | |||
} | |||
|
|||
&-form { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For editing cells we used overflow: visible
on cell content together with negative margins so that the editor can take more space inside a cell and its focus outline is not cut off. Instead, in the refactored versions we just use different paddings for editing cells and there is no longer an issue with the outline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: the overflow visible is still needed for editable content that includes dropdowns. I will contribute a new screenshot test to capture that.
@@ -90,6 +90,7 @@ export const TableTdElement = React.forwardRef<HTMLTableCellElement, TableTdElem | |||
collapseButtonLabel, | |||
verticalAlign, | |||
resizableColumns, | |||
resizableStyle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resizableStyle
replaces style
to make the cell API better predictable so that no unexpected attributes can be assigned from the outside.
@@ -53,6 +53,7 @@ | |||
|
|||
.table { | |||
inline-size: 100%; | |||
block-size: 100%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not affect the table itself - the size of the table is determined by the size of its content.
However, the table element needs the height set for cells height to take an effect, see discussion: https://stackoverflow.com/questions/3215553/make-a-div-fill-an-entire-table-cell.
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
block-size: 100%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making cell content span to the entire cell height.
@@ -101,6 +102,8 @@ export const TableTdElement = React.forwardRef<HTMLTableCellElement, TableTdElem | |||
const Element = isRowHeader ? 'th' : 'td'; | |||
const isVisualRefresh = useVisualRefresh(); | |||
|
|||
resizableStyle = resizableColumns ? {} : resizableStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition looks counterintuitive. you apply resizableStyle
only when resizableColumns
is false. why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is taken as is from the current impl: https://github.com/cloudscape-design/components/blob/main/src/table/internal.tsx#L627
When resizable columns is on, the styles are assigned directly to cell nodes in src/table/column-widths-utils.ts
and I think the properties like min-width and max-width are ignored.
I think there are further opportunities for refactoring and maybe this condition can be just removed but I'd not include this into the current PR.
I added a new commit with the following changes:
I will re-run the screenshot tests for these changes, too. |
Description
The PR refactors table body cell styles with the focus on editable cells. That is needed for the follow-up task to move editable cell style from the cell element to the cell content instead. This would allow having both row expand toggle and editable cell trigger in a single cell (in 1st column).
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
.CONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.