Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions modules/ui/sections/raw_membership_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment on lines +174 to +176
Copy link
Collaborator

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.

_showBlank = false;

function actionAddMembers(relationId, ids, role) {
Expand Down Expand Up @@ -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);
}


Expand Down