Skip to content

fix: [DHIS2-20985] Username field selects first suggestion instead of clicked user#4493

Open
henrikmv wants to merge 4 commits intomasterfrom
hv/fix/DHIS2-20985_UsernameSelector
Open

fix: [DHIS2-20985] Username field selects first suggestion instead of clicked user#4493
henrikmv wants to merge 4 commits intomasterfrom
hv/fix/DHIS2-20985_UsernameSelector

Conversation

@henrikmv
Copy link
Copy Markdown
Contributor

@henrikmv henrikmv commented Mar 20, 2026

DHIS2-20985

The UserField component has a search input with a suggestions dropdown. When focus leaves both the input and the suggestions, onExitSearch() is called to close the dropdown. This blur detection previously relied on checking getAttribute('name') on <div> elements, which is non-standard and fails when event.relatedTarget is a child element (e.g. inside ) that doesn't carry the name attribute.

This PR makes two fixes:

  1. Switches to data-suggestion-name for identifying suggestion elements in blur handlers, checked via element.dataset.suggestionName,
  2. Adds preventDefault() on mouseDown to prevent the classic blur-before-click race condition when clicking a suggestion.

Some existing bugs for long values are also been improved:

bilde Skjermbilde 2026-03-20 kl  19 55 06

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

@henrikmv henrikmv marked this pull request as ready for review March 20, 2026 18:06
@henrikmv henrikmv requested a review from a team as a code owner March 20, 2026 18:06
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 20, 2026

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully on 2.44,2.43.1,2.42.5,2.41.9,2.40.12 versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants