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

Unable to set scroll position of modal on opening #254

Open
TopsyCM opened this issue Jul 2, 2018 · 0 comments
Open

Unable to set scroll position of modal on opening #254

TopsyCM opened this issue Jul 2, 2018 · 0 comments
Labels

Comments

@TopsyCM
Copy link

TopsyCM commented Jul 2, 2018

I have a modal with a set of headings and copy. It has been styled so the modal content is scrollable. This all works fine, but it has been requested that the modal scroll to specific sections when opened. This seems straightforward enough, but I find I am unable to set the scroll position of any element inside of a modal because of ember-wormhole. Here is a brief outline of the implementation:

{{#if isShowingModal}}
  {{#modal-dialog}}
     ...

The action that toggles the value is set up as follows:

  toggleModal(shouldScroll) {
    this.toggleProperty('isShowingModal');
    scheduleOnce('afterRender', () => {
      if(shouldScroll) {
        // query the appropriate element in the modal DOM and set scroll
        ...

The code executes as expected, but... ember-wormhole also uses an afterRender hook to call _appendToDestination (this is in the init hook). _appendToDestination steps through the child nodes of the modal and calls insertBefore, reinserting each into its parent node. This "refresh" of the DOM resets the scroll position, undoing the scroll position set in my code.

How can I execute code after the dialog is opened and ember-wormhole has finished?
Is there a way to ensure my afterRender fires after ember-wormhole finishes its work?
Is there another way around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants