From d46dcea320616c5cca253599f4712dfa5a04346e Mon Sep 17 00:00:00 2001 From: Deeptanshu Sankhwar Date: Wed, 27 Nov 2024 06:19:43 -0700 Subject: [PATCH 1/4] Pass the reference explicitly to the function to ensure the correct context is available. --- modules/ui/sections/raw_membership_editor.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ui/sections/raw_membership_editor.js b/modules/ui/sections/raw_membership_editor.js index 6ce6d84992..4f45091f54 100644 --- a/modules/ui/sections/raw_membership_editor.js +++ b/modules/ui/sections/raw_membership_editor.js @@ -170,8 +170,10 @@ export function uiSectionRawMembershipEditor(context) { } - function addMembership(d, role) { - this.blur(); // avoid keeping focus on the button + function addMembership(d, role, domElement) { + if (domElement && typeof domElement.blur === 'function') { + domElement.blur(); // avoid keeping focus on the button + } _showBlank = false; function actionAddMembers(relationId, ids, role) { @@ -557,7 +559,7 @@ export function uiSectionRawMembershipEditor(context) { if (d.relation) utilHighlightEntities([d.relation.id], false, context); var role = context.cleanRelationRole(list.selectAll('.member-row-new .member-role').property('value')); - addMembership(d, role); + addMembership(d, role, this); } From 21f8f805e9a252f9a82ae9c68e6ab92fe0e0786d Mon Sep 17 00:00:00 2001 From: Deeptanshu Sankhwar Date: Sat, 30 Nov 2024 07:54:50 -0700 Subject: [PATCH 2/4] refactor: handle blur() in a closure to separate UI logic from addMembership --- modules/ui/sections/raw_membership_editor.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/ui/sections/raw_membership_editor.js b/modules/ui/sections/raw_membership_editor.js index 4f45091f54..e01d7988a7 100644 --- a/modules/ui/sections/raw_membership_editor.js +++ b/modules/ui/sections/raw_membership_editor.js @@ -170,10 +170,7 @@ export function uiSectionRawMembershipEditor(context) { } - function addMembership(d, role, domElement) { - if (domElement && typeof domElement.blur === 'function') { - domElement.blur(); // avoid keeping focus on the button - } + function addMembership(d, role) { _showBlank = false; function actionAddMembers(relationId, ids, role) { @@ -504,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 trigering element + acceptEntity.call(this, d); + }) .on('cancel', cancelEntity) ); @@ -555,11 +555,12 @@ export function uiSectionRawMembershipEditor(context) { cancelEntity(); return; } + // remove hover-higlighting if (d.relation) utilHighlightEntities([d.relation.id], false, context); var role = context.cleanRelationRole(list.selectAll('.member-row-new .member-role').property('value')); - addMembership(d, role, this); + addMembership(d, role); } From 10d2e422e7fc0f8461a368b7754e891ab5c34a89 Mon Sep 17 00:00:00 2001 From: Deeptanshu Sankhwar Date: Sat, 30 Nov 2024 07:56:00 -0700 Subject: [PATCH 3/4] spacing --- modules/ui/sections/raw_membership_editor.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ui/sections/raw_membership_editor.js b/modules/ui/sections/raw_membership_editor.js index e01d7988a7..365661b415 100644 --- a/modules/ui/sections/raw_membership_editor.js +++ b/modules/ui/sections/raw_membership_editor.js @@ -555,7 +555,6 @@ export function uiSectionRawMembershipEditor(context) { cancelEntity(); return; } - // remove hover-higlighting if (d.relation) utilHighlightEntities([d.relation.id], false, context); From 78cc893bd7ef2cde075da82db5fa22a71c38ff80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sat, 30 Nov 2024 22:41:45 -0800 Subject: [PATCH 4/4] Fixed typo --- modules/ui/sections/raw_membership_editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/sections/raw_membership_editor.js b/modules/ui/sections/raw_membership_editor.js index 365661b415..58f0d076dc 100644 --- a/modules/ui/sections/raw_membership_editor.js +++ b/modules/ui/sections/raw_membership_editor.js @@ -502,7 +502,7 @@ export function uiSectionRawMembershipEditor(context) { .on('blur', cancelEntity) // if it wasn't accepted normally, cancel it .call(nearbyCombo .on('accept', function(d) { - this.blur(); // always blurs the trigering element + this.blur(); // always blurs the triggering element acceptEntity.call(this, d); }) .on('cancel', cancelEntity)