Skip to content
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

Add remove method #54

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Add remove method #54

wants to merge 4 commits into from

Conversation

MasterKrab
Copy link

Add a method to remove the floating focus to be able to implement customizations in a simple way

Copy link
Collaborator

@Jirinrin Jirinrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right that it makes sense to have a method which removes the floating focus effect!

See my comments for nitpicks on how I'd personally like to see it implemented, and I'll ask my colleague for a quick second opinion (because I haven't been doing too much frontend stuff lately).

src/floating-focus.js Outdated Show resolved Hide resolved
src/floating-focus.js Outdated Show resolved Hide resolved
@@ -226,4 +235,9 @@ export default class FloatingFocus {
repositionElement(target, floater) {
Object.assign(floater.style, this.getFloaterPosition(target));
}

remove(){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We activate the floating focus effect by instantiating this with its constructor, so therefore I find it a bit strange to have a remove() method like this which then leaves the class sort of floating in space.
How about renaming this to deactivate() or disable() or something similar, and then also implementing an activate() or enable() method which can enable it again? (In the end that would only call addEventListeners again but it makes it clearer from the outside what you're doing)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right, it is clearer and more personalized.

src/floating-focus.spec.js Outdated Show resolved Hide resolved
@MasterKrab MasterKrab requested a review from Jirinrin February 22, 2022 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants