Skip to content

fix(ui): display of renamed items in AJAX dropdowns - #25048

Open
eduardomozart wants to merge 2 commits into
glpi-project:11.0/bugfixesfrom
eduardomozart:fix-issue-22905
Open

fix(ui): display of renamed items in AJAX dropdowns#25048
eduardomozart wants to merge 2 commits into
glpi-project:11.0/bugfixesfrom
eduardomozart:fix-issue-22905

Conversation

@eduardomozart

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

When an item (e.g., Software) is renamed from another tab, returning to an active tab and searching for it in an already-loaded AJAX dropdown successfully retrieves and displays the new name in the search results. However, clicking the item to select it causes the dropdown to revert and incorrectly display the old name (Closes #22905).

Cause
When an item is selected from AJAX results, Select2 checks if an <option> element with the corresponding ID already exists in the underlying <select> element. If it does (which happens because the item was present when the page initially loaded), Select2 reuses it. Because the <option> tag in the DOM still contains the old name, Select2 extracts the old text from it and uses it for the selection display, ignoring the newly fetched text from the AJAX payload.

Solution
Added a select2:selecting event listener to setupAjaxDropdown within js/common.js. This intercepts the selection just before Select2 applies it. It retrieves the latest text from the AJAX data payload and updates the underlying <option> element's text in the DOM. Consequently, when Select2 extracts the text to display the selection, it uses the correct, up-to-date name.

Screenshots (if appropriate):

Gravacao.de.Tela.2026-07-30.as.13.34.57.mov

Comment thread js/common.js Outdated
Co-authored-by: Curtis Conard <cconard96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updating asset name do not update it on existing Dropdown::show

2 participants