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 9 commits into
base: main
Choose a base branch
from

Conversation

PeikyLiu
Copy link

@PeikyLiu PeikyLiu commented Jun 30, 2025

🚀 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

resolve #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
ilyaliao
ilyaliao previously approved these changes Jul 4, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 4, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 18, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 19, 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 lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useFocusTrap | Implement updateContainerElements()
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy