You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disable autofocus of step content via step options #2117
I'd like to "re-discuss" #1588 - I have the same use case, in which I would like to keep an input in the highlighted app part focused, and not have the step popup take focus away. Currently, you use floating-ui to focus the step element after 300ms timeout (see here).
I understand that this is something where you would like to figure out a general strategy around a11y. In my case, I would however rather disable this behavior entirely via some step option autoFocus = false or something like that.
Would you accept a PR that introduces this ability, or you would not like to have such changes until you have a clearer position on this topic overall?
@DaDom I think we should find a way to add arbitrary elements into the focus trap that we implement. That way, we can keep what we have, but also allow adding more possible focus targets into the mix.
Great, that makes sense.
So, equivalent to StepOptionsAttachTo.element it might be a new step option like this - assuming that you may provide more than one selector/element:
Auto-focus the first matching element when the step is shown
Is that what you had in mind?
Btw., am I correct that you have chosen 300ms as delay before applying focus due to the css transition duration of 0.3s for shepherd-modal-overlay-container?
Alternatively, following your existing approach of finding all focusable elements here, we might also do the same inside of the resulting HTMLElement of StepOptionsAttachTo.element.
This could then be toggled with a simple boolean flag like this:
Me too!!
I'm new with shepherd, its the best js guiding tool (and I tested a lot!) but this described behavior, from my point of view, is a bug.
I have inputs that start an ajax action (saving) on focus lost. So currently I can not use them during highlighting.
(Exact workflow: click an element inside the highlighted element -> an input appears that increases the highlighted element -> the input gets focused -> shepherd does a redraw -> the focus of input gets lost -> input disappear)
hi this is reply to my question , for me it was not working because i was trying to open them in mat-dialog but and i had to remove and it started working , thank you
Activity
RobbieTheWagner commentedon Oct 24, 2022
@DaDom I think we should find a way to add arbitrary elements into the focus trap that we implement. That way, we can keep what we have, but also allow adding more possible focus targets into the mix.
DaDom commentedon Oct 24, 2022
Great, that makes sense.
So, equivalent to
StepOptionsAttachTo.elementit might be a new step option like this - assuming that you may provide more than one selector/element:Providing a value for this option will:
Is that what you had in mind?
Btw., am I correct that you have chosen 300ms as delay before applying focus due to the css transition duration of 0.3s for
shepherd-modal-overlay-container?DaDom commentedon Oct 24, 2022
Alternatively, following your existing approach of finding all focusable elements here, we might also do the same inside of the resulting HTMLElement of
StepOptionsAttachTo.element.This could then be toggled with a simple boolean flag like this:
Let me know what you think!
MaggusK commentedon Feb 12, 2023
Me too!!
I'm new with shepherd, its the best js guiding tool (and I tested a lot!) but this described behavior, from my point of view, is a bug.
I have inputs that start an ajax action (saving) on focus lost. So currently I can not use them during highlighting.
(Exact workflow: click an element inside the highlighted element -> an input appears that increases the highlighted element -> the input gets focused -> shepherd does a redraw -> the focus of input gets lost -> input disappear)
amitPurohit01 commentedon Aug 4, 2023
hi , is there any update on this bug, i am not able to highlight input element, but for text area it works fine
amitPurohit01 commentedon Aug 4, 2023
hi this is reply to my question , for me it was not working because i was trying to open them in mat-dialog but and i had to remove and it started working , thank you
crudobaker commentedon Sep 17, 2023
Hey!
I think the option of configuring the
autofocusproperty on step declaration is the best choice, like @DaDom proposal.For the moment, what works for my case is set the focus with a timeout, to override the autofocus on the current step.
In this example the
PressEnterOnTargetadvance on action listens theEnterevent on the target element to continue the tour.Hope it helps, and keep waiting for the improvement!
JakeThurman commentedon Mar 27, 2025
Running into some bugs because of the autofocus as well. I would love to see an option to disable it for a step.
fix(tour): prevent keyboard dismissal on touch devices, card ID N50