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

AttachTo doesn't find elements in ember-wormhole #343

Closed
BitBrit opened this issue Oct 3, 2019 · 11 comments
Closed

AttachTo doesn't find elements in ember-wormhole #343

BitBrit opened this issue Oct 3, 2019 · 11 comments

Comments

@BitBrit
Copy link

BitBrit commented Oct 3, 2019

Hi,

I am trying to create a tour, some of which goes through an ember-bootstrap modal. Ember-bootstrap modals use ember-wormhole.

I was hoping that I would be able to use the attachTo property and it would find elements and place the tooltip accordingly but unfortunately I get the console error stating that the element in the modal can't be found so it just places the tool tip in the center of the viewport.

Is there any work around/technique that I can use to make this work or is this just completely not supported?

Thanks in advance.

@RobbieTheWagner
Copy link
Owner

Hi @BitBrit it should support targeting any elements in the DOM. Do you have a small reproduction we could play with?

@BitBrit
Copy link
Author

BitBrit commented Oct 3, 2019

I don't yet, but let me see what I can put together. Actually, knowing that it should be able to target these elements helps.

@RobbieTheWagner
Copy link
Owner

@BitBrit I do not know what wormhole does, but any elements under body should work.

@BitBrit
Copy link
Author

BitBrit commented Oct 3, 2019

Ok, then perhaps it's a timing thing. It could be looking for the element in the modal before the modal has finished rendering.

@BitBrit
Copy link
Author

BitBrit commented Oct 3, 2019

Hi @rwwagner90 Thank you for your prompt responses. My suggestion above was correct. I had to find a way to advance the tour only when the modal had completed it's rendering. This means "advanceOn" wasn't usable without creating some other special event for it to listen to.

@BitBrit BitBrit closed this as completed Oct 3, 2019
@RobbieTheWagner
Copy link
Owner

@BitBrit glad you figured it out! I typically suggest not to use advanceOn and to manually call tour.next, so you can fully control everything.

@BitBrit
Copy link
Author

BitBrit commented Oct 4, 2019

That sounds good but the reason I used advanceOn was because I didn't want the tour logic/knowledge to bleed throughout the app. But yes, it seems to have its short-comings.

@RobbieTheWagner
Copy link
Owner

RobbieTheWagner commented Oct 4, 2019

@BitBrit Sure, that makes sense. I'm open to suggestions to making advanceOn better, but I think making a custom event that is sure the element is visible might be the best option. We could also maybe have Shepherd continue to try to find the element to attach to every like 500ms or something.

@BitBrit
Copy link
Author

BitBrit commented Oct 22, 2019

@rwwagner90 that would be really good.

We are also using ember-bootstrap with a dropdown-menu element. Our tour spans this dropdown menu and so we have to wait for it to exist. ember-bootstrap usually has a way to pass an onShown() action handler. However, for dropdown menus, it does not. This meant that we had to develop our own way of trying to detect when the menu has finished opening and is in the DOM.

We thought about adding some sort of timeout after which we would know for certain the menu had finished transitioning to being open but this felt a little "hacky". So, rightly or wrongly, we decided to use this:

https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver

So that it doesn't become a performance problem we scoped the conditions as to when this would fire as tightly as possible. Your suggestion would mean that we wouldn't have to implement things like this to handle transitions.

@RobbieTheWagner
Copy link
Owner

@BitBrit can we add an onShown to ember-bootstrap perhaps? I think it feels more correct to know for sure when the thing is rendered, and then fire the event, rather than polling.

@BitBrit
Copy link
Author

BitBrit commented Oct 25, 2019

@rwwagner90 I agree. Being told when something has happened is always better than asking repeatedly. I will look into making a PR for that.

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

No branches or pull requests

2 participants