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

Resize preference save sequence #233

Merged
merged 3 commits into from
Sep 20, 2023
Merged

Conversation

joelamb
Copy link
Contributor

@joelamb joelamb commented Sep 19, 2023

Turns out that this: #211 (comment) came back to bite us! The test was passing, but waiting in the test-helper was masking the resizing behaviour and causing unpredictable column resizing when interacting with tables.

What was happening:
Calling the resize function via a requestAnimationFrame in the queueUpdate pushes it into the next animation frame, however, the call to save the preferences was then happening ahead of it, so the saved values did not reflect the resizing.

We'd created a pseudo-async sequence.

How these changes fix it:
So, to ensure that preferences are saved after we have completed resizing, we pass the save function as a callback to the queueUpdate that can then be called in the requestAnimationFrame callback after the resize function.

Because the requestAnimationFrame hides these function call from he ember test waiter, we ensure that we track them by also cancelling the waiter in the requestAnimationFrame callback function.

@changeset-bot
Copy link

changeset-bot bot commented Sep 19, 2023

🦋 Changeset detected

Latest commit: 4dbf668

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
ember-headless-table Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2023

the queueUpdate was uses requestFrameAnimation to schedule the calls
to the resize columns function.
To ensure that the call to save preferences is called after the resize
the queueUpdate now takes an optional callback function that is called
after the resize.
This ensures that these pseudo-async events are always performed in a
predictable and correct sequence.
Test helpers simplified since we now handle test waiting in the
queueUpdate function of the resize handle.
Column resizing test updated to affect multiple columns and more
explicitly check the width of the adjusted columns, not just verify
the delta.
@joelamb joelamb force-pushed the resize-preference-save-sequence branch from 7bb7613 to e455891 Compare September 20, 2023 08:35
@joelamb joelamb merged commit dad73fc into main Sep 20, 2023
@joelamb joelamb deleted the resize-preference-save-sequence branch September 20, 2023 19:03
@github-actions github-actions bot mentioned this pull request Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants