Skip to content
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

[BUG] Fix positioning of table footer rows when rows are of varying heights #837

Merged
merged 2 commits into from
Nov 17, 2020

Conversation

jiayingxu
Copy link
Contributor

@jiayingxu jiayingxu commented Oct 27, 2020

The TableStickyPolyfill is used to position header and footer rows. The individual th and td offset positions are calculated for the footer rows so they remain “sticky”. There is a bug in the logic for calculating the bottom offset for table footer rows where the rows were being iterated backwards while the heights were iterated forwards. This bug manifests when table footer rows have varying heights and the list of heights is not a palindrome.

As shown in the image below, the table has 7 footer rows where the height of the 1st footer row is 74px and the height of all other footer rows is 26px. The bottom offset of the 6th row takes into account the height of the 1st row and not the 7th row due to the loop iteration direction bug.
The list heights: [74, 26, 26, 26, 26, 26, 26] is errantly being read in reverse order as heights: [26, 26, 26, 26, 26, 26, 74].
The ember-twiddle demonstrates the issue here.

image

@jiayingxu jiayingxu changed the title Fix positioning of table footer rows when rows are of varying heights [BUG] Fix positioning of table footer rows when rows are of varying heights Oct 27, 2020
@jiayingxu jiayingxu force-pushed the jiayingxu/table-sticky-footer-offset-fix branch from 3716d2d to 930440e Compare October 27, 2020 16:05
@jiayingxu jiayingxu marked this pull request as ready for review October 27, 2020 17:47
@bantic bantic force-pushed the jiayingxu/table-sticky-footer-offset-fix branch from 5fc2687 to 930440e Compare November 2, 2020 21:08
@jiayingxu jiayingxu force-pushed the jiayingxu/table-sticky-footer-offset-fix branch from 930440e to 63b5b51 Compare November 6, 2020 23:33
@jiayingxu jiayingxu changed the base branch from master to 3.0-beta November 6, 2020 23:33
Copy link
Contributor

@bantic bantic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fix looks good! 👏

Is there a way to confirm that the table header/footer rows do indeed span multiple lines, in the tests? Is it just the length of the prefix text that makes them take multiple lines? If the table were wider, would they cease being multiline rows?

Is it possible to, for instance, amend the tests with an assertion that the rows are indeed inequal heights?

Provisional ✔️ pending addressing ^.

@jiayingxu
Copy link
Contributor Author

@bantic, good point about verifying that the table header/footer rows span multiple lines. Currently, it is dependent on the length of the prefix text and the width of the table.

I've added a pre-condition assertion to verify that the header/footer rows have unequal heights.

@jiayingxu jiayingxu force-pushed the jiayingxu/table-sticky-footer-offset-fix branch from e88b7ad to 680f71d Compare November 17, 2020 01:35
@jiayingxu jiayingxu force-pushed the jiayingxu/table-sticky-footer-offset-fix branch from 680f71d to 50d74f4 Compare November 17, 2020 21:31
@jiayingxu jiayingxu merged commit e4c5ae6 into 3.0-beta Nov 17, 2020
@delete-merged-branch delete-merged-branch bot deleted the jiayingxu/table-sticky-footer-offset-fix branch November 17, 2020 22:00
@bantic bantic mentioned this pull request Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants