Skip to content

Commit

Permalink
Ensure correct this context for addMembership function to call the bl…
Browse files Browse the repository at this point in the history
…ur method correctly. Fixes #10555 (#10560)

* Pass the  reference explicitly to the  function to ensure the correct context is available.

* refactor: handle blur() in a closure to separate UI logic from addMembership

* spacing

* Fixed typo

---------

Co-authored-by: Deeptanshu Sankhwar <deeptanshu@walletsocket.com>
Co-authored-by: Minh Nguyễn <mxn@1ec5.org>
  • Loading branch information
3 people authored Dec 1, 2024
1 parent 3025d4f commit e48aa3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/ui/sections/raw_membership_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export function uiSectionRawMembershipEditor(context) {


function addMembership(d, role) {
this.blur(); // avoid keeping focus on the button
_showBlank = false;

function actionAddMembers(relationId, ids, role) {
Expand Down Expand Up @@ -502,7 +501,10 @@ export function uiSectionRawMembershipEditor(context) {
newMembership.selectAll('.member-entity-input')
.on('blur', cancelEntity) // if it wasn't accepted normally, cancel it
.call(nearbyCombo
.on('accept', acceptEntity)
.on('accept', function(d) {
this.blur(); // always blurs the triggering element
acceptEntity.call(this, d);
})
.on('cancel', cancelEntity)
);

Expand Down

0 comments on commit e48aa3c

Please sign in to comment.