Skip to content

Fixed dropdown lazy initialization for dynamically populated translation selects#1834

Open
mikadamczyk wants to merge 1 commit intomainfrom
admin-ui-dropdown-lazy-options-fix
Open

Fixed dropdown lazy initialization for dynamically populated translation selects#1834
mikadamczyk wants to merge 1 commit intomainfrom
admin-ui-dropdown-lazy-options-fix

Conversation

@mikadamczyk
Copy link
Contributor

🎫 Issue N/A

Related PRs:

Description:

This PR fixes an ibexa.core.Dropdown initialization edge case that caused empty option lists in dynamically populated translation modals (for example, the Content Tree “Add translation” modal).

The regression appeared when a dropdown was initialized while its underlying <select> had no options yet, and the options were added later by JavaScript. In that case, the dropdown instance was left in a partially initialized state and did not properly reflect later option updates.

Root cause:

Dropdown.init() returned early when the source <select> had no options. This prevented full UI initialization (itemsPopover) and also blocked proper refresh behavior for options added later.

As a result, consumers who dynamically rebuild <select> options (like Content Tree translation modal) ended up with:

  • native <select> containing correct options
  • custom dropdown UI still showing an empty list
What changed
  • Introduced deferred/lazy UI initialization path in ibexa.core.Dropdown
  • Extracted dropdown UI setup into initializeDropdownUI()
  • Attached observers before the "no options" early return
  • When options are added later, the mutation observer now:
    • completes dropdown UI initialization (if not initialized yet)
    • then calls recreateOptions()
Why this fix is in admin-ui

The issue is in the shared dropdown component lifecycle, not in Content Tree logic itself. Fixing it in admin-ui removes the need for consumer-level workarounds (manual instance reset / re-init) and benefits any feature that uses dynamically populated dropdown options. If this fix is merged, then https://github.com/ibexa/content-tree/pull/113 should be closed.

Impact
  • Fixes empty source language list in Content Tree “Add translation” modal (first open)
  • Keeps existing dropdown behavior unchanged for statically initialized dropdowns

For QA:

Documentation:

@mikadamczyk mikadamczyk self-assigned this Feb 24, 2026
@sonarqubecloud
Copy link

@mikadamczyk mikadamczyk marked this pull request as ready for review February 24, 2026 11:24
@mikadamczyk mikadamczyk requested a review from a team February 24, 2026 11:24
@ibexa-workflow-automation-1 ibexa-workflow-automation-1 bot removed the request for review from a team February 24, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants