-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ensure correct this context for addMembership function to call the blur method correctly. Fixes #10555 #10560
Ensure correct this context for addMembership function to call the blur method correctly. Fixes #10555 #10560
Conversation
…ontext is available.
if (domElement && typeof domElement.blur === 'function') { | ||
domElement.blur(); // avoid keeping focus on the button | ||
} |
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.
This is a defensive fix, but since addMembership
is only called from one place, I think it would be cleaner to move this blur
call to the caller, or even replace this with a closure that blurs the element, which would explicitly be in scope:
.on('accept', acceptEntity) |
As it is, if acceptEntity
has to bail for some reason, it won’t blur the element, which might result in the menu getting stuck on screen.
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.
Thank you for the suggestion @1ec5 ! I completely agree that handling the blur() in a closure at the .on('accept') level would ensure the element is blurred reliably and keeps the UI logic separate from addMembership. I will updat the code to use the closure approach, which explicitly handles the blurring before calling acceptEntity.
I've updated the PR with the updated code to use the closure approach, which explicitly handles the blurring before calling acceptEntity. This change aligns with the feedback and avoids potential issues with the menu getting stuck on screen. Let me know if there are any further adjustments you'd recommend! 🙌 |
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.
Thanks, and congratulations on your first contribution!
Thank you very much @1ec5 ! Hoping to be more involved. |
Fixes issue #10555
this
reference explicitly to theaddMembership
function to ensure the correct context is available.this
was undefined due to implicit context binding in event handlers.acceptEntity
to pass the triggering DOM element explicitly as a parameter.