Skip to content

fix(bootstrap-admin-ui): rebind tooltips after a live component re-render - #393

Open
Rafikooo wants to merge 1 commit into
Sylius:mainfrom
Rafikooo:fix/tooltips-after-live-render
Open

Rafikooo wants to merge 1 commit into
Sylius:mainfrom
Rafikooo:fix/tooltips-after-live-render

Conversation

@Rafikooo

@Rafikooo Rafikooo commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Tooltips are bound once, on page load. Any data-bs-toggle="tooltip" inside a live component (a form, a grid) loses its tooltip as soon as the component re-renders: new elements never get one, and morphed ones keep the title from before the render.

The init now also runs on every render:finished of each live component, scoped to that component's element, using the live:connect hook from the UX docs. A trigger that already has an instance gets it disposed first, so the fresh title is picked up.

The logic moved to scripts/tooltips.js so it can be covered by the existing node --test suite without a browser. public/ is not rebuilt, as with the other source-only fixes.

@loic425

loic425 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Thanks for the fix! Looks good overall, two notes:

  1. Assets: public/ needs to be rebuilt, otherwise the fix won't reach apps using the prebuilt app.js.

  2. Stale title from the second re-render onwards: Live Component's ExternalMutationTracker records attribute changes made by external JS while the component is connected, and re-applies them on the next morph. So:

    • after render 1, new Tooltip() runs _fixTitle(), which sets data-bs-original-title="B" and removes title. The tracker records both changes;
    • on render 2, the server sends title="C", but the tracker re-applies data-bs-original-title="B" and removes title again;
    • dispose() then restores title="B" from data-bs-original-title, and the new instance picks up B.

    I reproduced it in a browser (ux-live-component 2.35, Bootstrap 5.3.9, with the backend mocked to return an incremented title on each render). The tooltip shows "Title 1" for the 2nd and 3rd renders. The unit test uses fakes, so it can't catch this.

    Using data-bs-title instead of title avoids it: Bootstrap reads the title from its config and doesn't touch the DOM, so the tracker has nothing to replay. In the same repro, it followed the server on every render.

    After 3 re-renders, the server sends "Title 3" to both components. The first uses title, the second data-bs-title:

    Tooltip after 3 re-renders: Title 1 with title, Title 3 with data-bs-title

@loic425

loic425 commented Nov 23, 2026

Copy link
Copy Markdown
Member

To clarify point 2: nothing to change in this PR, all Stack templates already use data-bs-title, which works fine. It only affects app templates that use title on tooltip triggers inside live components, so maybe worth a line in the docs.

This branch has not been deployed

No deployments
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.

2 participants