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

Fork ember-url-hash-polyfill and remove 2-second delay for our use case #1

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

robinaugh
Copy link
Collaborator

@robinaugh robinaugh commented Oct 10, 2022

See https://github.com/emporatitle/ember-url-hash-polyfill#ember-url-hash-polyfill for the rationale for ember-url-hash-polyfill's existence.

For Empora, the lack of support in Ember for page anchors is preventing us from being able to route back to the action items section of the deal page after creating/updating an action item, and as we continue to build functionality in Ember, it'll be expected that this basic browser functionality will be supported.

I've been able to get the original ember-url-hash-polyfill working with Reggie, but it has a hardcoded delay while it waits for animation frames to finish, which means it takes 2 seconds to scroll down to the page anchor, at which point the user has probably already scrolled away to wherever they want to go.

Because we don't have a ton of animation in Reggie (and are unlikely to add much in the future), this delay can be removed for our use case.

As recently as August 2022, a member of the core Ember team said that they were working on first-class support for this problem (emberjs/rfcs#709 (comment)), so hopefully this fork is temporary. If it proves not to be, I may PR a change to the original ember-url-hash-polyfill to make this configurable instead.

@robinaugh robinaugh self-assigned this Oct 10, 2022
@robinaugh robinaugh marked this pull request as ready for review October 10, 2022 15:05
@@ -117,7 +115,7 @@ async function setupHashSupport(router: EmberRouter) {

const CACHE = new WeakMap<ApplicationInstance, MutationObserver>();

async function eventuallyTryScrollingTo(owner: ApplicationInstance, url?: string) {
function eventuallyTryScrollingTo(owner: ApplicationInstance, url?: string) {
Copy link

Choose a reason for hiding this comment

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

Does this need to be called eventually try scrolling if there is no longer a delay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably not - I was trying to minimize changes to the original project, but if people feel strongly about it, I can rename.

Copy link

@lizheym lizheym left a comment

Choose a reason for hiding this comment

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

🦎

@robinaugh robinaugh merged commit b65415f into main Oct 10, 2022
@robinaugh robinaugh deleted the jason/scroll-without-timeout branch October 10, 2022 17:33
return resolve(totalTimeWaited);
}

schedule('afterRender', requestTimeCheck);

Choose a reason for hiding this comment

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

this is the actual bug here, it will always mutate DOM.

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