Ensure correct this context for addMembership function to call the blur 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>
This commit is contained in:
Deeptanshu Sankhwar
2024-11-30 23:43:54 -07:00
committed by GitHub
parent 3025d4f421
commit e48aa3c2c4

View File

@@ -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)
);