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
feat: remove clrFocusTrap
in favor of @angular/cdk
#431
Conversation
Thank you, 🤖 Clarity Release Bot |
13cee0b
to
02534f3
Compare
There is already a newer implementation of a focus trap in the code that proved itself useful. What is the need of introducing a new package that provides the same thing and on top of that introducing a dependency we have no control of? |
This is about redundancy. I'm proposing eliminating custom code for things that Angular provides. I think it is unnecessary/redundant/inefficient for us to maintain custom implementations of drag/drop, focus trap, list key focus, etc. These things are provided by Angular. It's just not the best use of time/people/the team. The Angular CDK is maintained by the same team that maintains the Angular framework packages, so in my view, it's just part of depending on Angular. As a user, I'd expect an Angular component library to use and rely on the Component Development Kit because that's what it's for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, apart from the demo page failing.
It may be demo-specific, as the modal is pre-open and inline, but it would be great if you can take a look.
I would advice testing these changes in a real application before the actual release cause this could be a real issue if someone depends on the |
If you could test There will be prereleases, but you don't need to wait for this to be released to adopt the CDK. |
02534f3
to
2fc35fd
Compare
@Jinnie: I just forgot to import the |
@kevinbuhmann Adding a dependency on @angular/cdk is a significant architectural decision for Clarity Angular. In this initial step, your desire to avoid duplication of a smallish piece of code to deal with focus trapping could cause bundle sizes to increase in all consuming applications by over 100K (uncompressed) because the cdkFocusTrap directive is part of the @angular/cdk/a11y entrypoint. I would be interested to know how well the Angular 15 build system can tree-shake the unused code out. Have you done any experiments to see how the addition of this new dependency increases application bundle size? |
@elesueur Angular is generally very well architected for tree shaking. It is certainly more tree-shakable that Clarity itself which is a problem I hope to tackle for v15 with should help offset this. Additionally, the focus trap is not the only piece of code I wish to replace with CDK. See my other PRs. |
The CDK is built for exactly this use case: component library development. I don't see any reason why we should maintain custom code for things the framework provides for us. |
6e227b7
to
95c4b8f
Compare
My last two force pushes avoid importing all of |
5118fe6
to
c28032b
Compare
I support what Kevin shared above. |
The `debugElement.query` method returns `null` for not found. The `null` value is considered "defined" in JavaScript, so `toBeDefined` is not an appropriate matcher for this test.
BREAKING CHANGE: The `clrFocusTrap` directive has been removed. Please use the `cdkTrapFocus` directive from `@angular/cdk` instead.
c28032b
to
c417bf6
Compare
🎉 This PR is included in version 15.0.0-beta.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed PRs after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary. |
PR Checklist
PR Type
Remove undocumented feature.
What is the current behavior?
Various components use custom focus trap functionality, and this custom functionality is exported by the library.
What is the new behavior?
Various components use focus trap functionality from @angular/cdk, and the custom functionality is removed.
Does this PR introduce a breaking change?
Yes.
@angular/cdk
package is now a required peer dependency.clrFocusTrap
directive has been removed. Please use thecdkTrapFocus
directive from@angular/cdk
instead.