Skip to content

Restore attachTo tabindex when tour is hidden#3351

Merged
RobbieTheWagner merged 1 commit intomainfrom
restore-tabindex
Feb 5, 2026
Merged

Restore attachTo tabindex when tour is hidden#3351
RobbieTheWagner merged 1 commit intomainfrom
restore-tabindex

Conversation

@RobbieTheWagner
Copy link
Member

@RobbieTheWagner RobbieTheWagner commented Feb 5, 2026

Fixes #3334

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed tabindex handling to properly preserve and restore the original keyboard focus attributes of elements during tour steps
    • Elements now correctly return to their original accessibility state after tour completion, improving focus management and keyboard navigation

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shepherd-docs Ready Ready Preview, Comment Feb 5, 2026 2:58pm
shepherd-landing Ready Ready Preview, Comment Feb 5, 2026 2:58pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The changes implement tabindex preservation for Shepherd.js tour steps. When a step attaches to an element and forces it focusable by setting tabIndex to 0, the original tabindex value is stored. Upon step hide or destruction, the original tabindex is restored (or the attribute is removed if none previously existed).

Changes

Cohort / File(s) Summary
Svelte Component Integration
shepherd.js/src/components/shepherd-element.svelte
Calls step._storeOriginalTabIndex() to capture the original tabindex before forcing focusability.
Core State & Lifecycle Management
shepherd.js/src/step.ts
Introduces _originalTabIndexes Map to track original values; adds _storeOriginalTabIndex() and _restoreOriginalTabIndexes() methods; integrates restoration into show/hide lifecycle and destruction.
Test Suite
shepherd.js/test/unit/step.spec.js
Adds "tabIndex preservation" test suite with 6 scenarios covering no-tabindex, negative values, positive values, destruction during tour, multiple cycles, and intermediate changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A tour through indices, stored with care,
Original values preserved everywhere,
When steps do hide and tours complete,
Restored to home, the circles sweet! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: restoring the original tabindex attribute of the attach-to element when the tour is hidden, which is the core functionality added across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch restore-tabindex

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qltysh
Copy link

qltysh bot commented Feb 5, 2026

Qlty

Coverage Impact

⬆️ Merging this pull request will increase total coverage on main by 0.21%.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
shepherd.js/src/step.ts100.0%
Coverage rating: B Coverage rating: B
shepherd.js/src/components/shepherd-element.svelte100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@RobbieTheWagner RobbieTheWagner merged commit 594b551 into main Feb 5, 2026
9 checks passed
@RobbieTheWagner RobbieTheWagner deleted the restore-tabindex branch February 5, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

attachTo element tabindex attribute gets modified

1 participant