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

Added support to open Shepherd inside <dialog> elements with the correct offset. #191

Closed
wants to merge 3 commits into from

Conversation

MarkusBordihn
Copy link

Fixed #157 with Popper.js implementation.

document.body.appendChild(this.el);

// Handling open dialog elements.
if (document.querySelector('dialog[open]')) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not super familiar with dialog elements, but wouldn't it be possible someone could have one open, but still want to append to the body instead?

Copy link
Author

@MarkusBordihn MarkusBordihn Jul 8, 2018

Choose a reason for hiding this comment

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

Normally open dialog elements having the main focus and getting closed after an specific action is performed like window.confirm() or window.promt().
Example: https://codepen.io/Garbee/pen/EPoaMj

Copy link
Member

Choose a reason for hiding this comment

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

Right, but it is possible you would have an open dialog and still want to not attach your steps to it. I think a better solution to this problem might be to allow passing a context and default to document.body when one is not passed. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

I see the general scenarios:

  1. Main window has steps, Dialog has steps.
  2. Main window has no steps, Dialog has steps.
  3. Main window has steps, Dialog has no steps.

All three scenarios are covered in this case:

  1. Steps are attached to body. Dialog gets open. Dialog steps are attached to the Dialog.
  2. Dialog gets open. Dialog steps are attached to the Dialog.
  3. Steps are attached to body.

Edge Case:
The dialog gets open before the main window adding the steps.
This should theoretical never happen, because such dialog normally only shown on user interaction or after the main content is rendered.

Did I miss anything?

RobbieTheWagner added a commit that referenced this pull request Jul 11, 2018
@RobbieTheWagner
Copy link
Member

@MarkusBordihn perhaps I was not being clear, but I have opened a PR, in which you can pass renderLocation, as either a string for the selector, or an HTMLElement which allows you to determine the container the step renders in.

That way, we can support rendering in any element, not just handle dialogs, and this gives greater flexibility. Please check it out and let me know if it will work for you #192.

@MarkusBordihn
Copy link
Author

@rwwagner90
Thanks for the info. I justed tested #192 with our current implementation and it seems that Propper is not considering the offset correctly for dialog elements.
This means if you provide renderLocation you should provide an options to correct the offset as well.

@RobbieTheWagner
Copy link
Member

@MarkusBordihn the same would also be true of this PR, right? Or did I mess something up?

@MarkusBordihn
Copy link
Author

@rwwagner90
Yes, it would be the same with this PR. But if your PR includes the options to adjust the offset or something like I could use this for testing and providing an auto correction if there is any interest.

@RobbieTheWagner
Copy link
Member

@MarkusBordihn popper.js supports offsets already. Perhaps try changing styles or offsets via popperOptions on the step? https://popper.js.org/popper-documentation.html#modifiers..offset

@MarkusBordihn
Copy link
Author

@rwwagner90 I just tested the latest version and it works well with native dialogs if you define the defaultStepOptions together with tippyOptions for e.g.:

let tour = new Shepherd.Tour({
    'defaultStepOptions': {
      'showCancelLink': true,
      'tippyOptions': {
        'appendTo': document.getElementById('id_of_the_dialog_element')
      },
    },
  });

Thanks a lot for improving Shepherd and keep it up to date. ;)

@RobbieTheWagner
Copy link
Member

You're welcome @MarkusBordihn! Glad it is working well for you 😃

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.

Attach shepherd-step to "custom" element / supporting dialog elements.
2 participants