CrowdStrike / ember-headless-table

https://ember-headless-table.pages.dev
MIT License
23 stars 7 forks source link

Resize preference save sequence #233

Closed joelamb closed 1 year ago

joelamb commented 1 year ago

Turns out that this: https://github.com/CrowdStrike/ember-headless-table/pull/211#discussion_r1283447227 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[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 4dbf6682b4b85d27e57821c68a82b376256121e1

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[bot] commented 1 year ago

Preview URLs

GH Env: preview docs: https://30782fc8.ember-headless-table.pages.dev api docs: https://30782fc8.ember-headless-table.pages.dev/api/modules.html