Skip to content

feat(useFocusTrap): expose updateContainerElements for dynamic contai… #4849

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PeikyLiu
Copy link

🚀 Feature: Expose updateContainerElements method in useFocusTrap

Description

This PR exposes the updateContainerElements method from the underlying focus-trap library, allowing users to dynamically update focus trap containers while the trap is active.

Related Issues

Implements #4848

📋 Changes

  • Added updateContainerElements method to UseFocusTrapReturn interface
  • Created ContainerElements type alias using Parameters<FocusTrap['updateContainerElements']>[0]
  • Updated return type to handle undefined case when trap is not initialized
  • Added basic container switching demo in demo.vue

🔧 Technical Details

  • Uses TypeScript's Parameters utility type to automatically inherit parameter types from focus-trap library
  • Ensures type consistency with the underlying focus-trap library

📚 Example Usage

const { updateContainerElements, activate } = useFocusTrap(target)
activate()
updateContainerElements(target2.value) // Switch to different container

🔄 Breaking Changes

None - this is a purely additive change.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant