From e48aa3c2c404266b165eb7b5186e683916ab8b20 Mon Sep 17 00:00:00 2001 From: Deeptanshu Sankhwar <31755863+Deeptanshu-sankhwar@users.noreply.github.com> Date: Sat, 30 Nov 2024 23:43:54 -0700 Subject: [PATCH] Ensure correct this context for addMembership function to call the blur method correctly. Fixes #10555 (#10560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Co-authored-by: Minh Nguyễn --- modules/ui/sections/raw_membership_editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ui/sections/raw_membership_editor.js b/modules/ui/sections/raw_membership_editor.js index 6ce6d84992..58f0d076dc 100644 --- a/modules/ui/sections/raw_membership_editor.js +++ b/modules/ui/sections/raw_membership_editor.js @@ -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) { @@ -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) );