- Issue created by @zilloww
- π¨πSwitzerland zilloww
Update:
I have identified the root cause of the issue.
The error occurs in the cancel handler of the Shepherd tour, at this line:
that.el.focus();
This line assumes that the tour toggle button (el) is present and focusable. However, for non-admin users who do not have the admin toolbar, the expected DOM element (.js-tour-start-button or .js-tour-start-toolbar) is missing. As a result, el is undefined, and calling .focus() throws a TypeError.
What I donβt fully understand is why the tour attempts to focus the admin toolbar toggle element after cancelling β it seems unnecessary and causes issues when that element doesn't exist (e.g. for non-admin users).Proposed fix:
I added a safe fallback before calling .focus():if (that.el && typeof that.el.focus === 'function') { that.el.focus(); }
With this in place:
- The overlay and URL parameter are properly cleared.
- No error is thrown when ending the tour as a non-admin user.
Iβll open a merge request shortly to propose this fix.
- Merge request !101Issue #3532065: Safely handle missing tour toggle element on cancel β (Closed) created by zilloww
- π¨πSwitzerland zilloww
zilloww β changed the visibility of the branch 2.0.x to hidden.
- π¨πSwitzerland zilloww
@smustgrave Just noticed that the MR pipeline failed and I don't really know why.
I see that there is the issue #3532135 concerning this pipeline that has been opened. Is it related?Can we review MR 101 to fix this issue ASAP as it's impacting the core functions of the module?
- π¨πSwitzerland zilloww
I just created a working .patch file for the version 2.0.10 while waiting an answer to this issue.
- πΊπΈUnited States smustgrave
Seems to be a duplicate of π Fix uncaught TypeError in Tour module by validating focus() and currentStep usage in Shepherd callbacks Active