fix(ui): display of renamed items in AJAX dropdowns - #25048
Open
eduardomozart wants to merge 2 commits into
Open
fix(ui): display of renamed items in AJAX dropdowns#25048eduardomozart wants to merge 2 commits into
eduardomozart wants to merge 2 commits into
Conversation
cconard96
requested changes
Aug 2, 2026
Co-authored-by: Curtis Conard <cconard96@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Please delete options that are not relevant.
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:selectingevent listener tosetupAjaxDropdownwithinjs/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