Skip to content

Fix(preview-middleware-client): rta causing duplicate ID when navigating from launchpad#4465

Merged
heimwege merged 13 commits intomainfrom
fix/preview-middleware-client/rta-duplicate-id-when-navigating-from-launchpad
Apr 1, 2026
Merged

Fix(preview-middleware-client): rta causing duplicate ID when navigating from launchpad#4465
heimwege merged 13 commits intomainfrom
fix/preview-middleware-client/rta-duplicate-id-when-navigating-from-launchpad

Conversation

@heimwege
Copy link
Copy Markdown
Contributor

@heimwege heimwege commented Mar 25, 2026

Issue

When opening the RTA (UI Adaptation) editor endpoint URL without an intent hash in the URL (e.g. /editor.html instead of /editor.html#app-preview), the user lands on the FLP sandbox home page. Navigating from there to the actual app triggered the error:

▎ "UI Adaptation could not be started - Error: adding element with duplicate id 'sapUIRta_toolbar'"

Root cause

The attachAppLoaded callback in flp/init.ts fires for every component loaded in the FLP shell — including the FLP home component (#Shell-home). Both the home component load and the subsequent app navigation each called startAdaptation, which attempted to create a RuntimeAuthoring toolbar with the fixed UI5 element ID sapUIRta_toolbar. The second creation failed with a duplicate ID error.

Fix

Added a guard at the start of the attachAppLoaded callback that skips RTA initialization when the URL hash is empty or equals #Shell-home. RTA will only start when the FLP has navigated to an actual application intent.

Code quality

All usages of window.location in flp/init.ts (hash, search, reload) have been replaced with globalThis.location as required by Sonar. In jsdom (the Jest environment), globalThis === window, so no test changes were required for this. The eslint.config.js was updated to ecmaVersion: 2020.

Test corrections

While fixing the failing tests caused by the guard (which requires a non-empty, non-Shell-home hash), a pre-existing bug in the 'flex configured & ui5 version is 1.71.60' test was uncovered and corrected.

For UI5 versions below 1.84, initConnectors() calls sap.ui.require with enableFakeConnector during init() setup — before attachAppLoaded fires. This means sap.ui.require.mock.calls[0] is the enableFakeConnector call, and the actual initRta callback is at index [1]. The original test was using mock.calls[0][1], accidentally extracting the wrong callback and silently testing enableFakeConnector instead of initRta. The index has been corrected to mock.calls[1][1].

@heimwege heimwege requested a review from a team as a code owner March 25, 2026 15:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 25, 2026

🦋 Changeset detected

Latest commit: 1b26214

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@sap-ux-private/preview-middleware-client Patch
@sap-ux/preview-middleware Patch
@sap-ux/eslint-plugin-fiori-tools Patch
@sap-ux/create Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@heimwege
Copy link
Copy Markdown
Contributor Author

@schiwekM FYI

@heimwege heimwege changed the title Fix(preview-middleware-client): rta duplicate id when navigating from launchpad Fix(preview-middleware-client): rta causing duplicate ID when navigating from launchpad Mar 25, 2026
@nikmace nikmace self-requested a review March 26, 2026 09:00
nikmace
nikmace previously approved these changes Mar 26, 2026
Copy link
Copy Markdown
Contributor

@nikmace nikmace left a comment

Choose a reason for hiding this comment

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

Changes look good
Changeset is OK
Coverage is good
Did not test manually

ytpo-lyne
ytpo-lyne previously approved these changes Mar 26, 2026
Copy link
Copy Markdown
Contributor

@ytpo-lyne ytpo-lyne left a comment

Choose a reason for hiding this comment

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

  • code changes for RTA endpoints look good
  • changeset present
  • excellent coverage
  • did not test manually

Approving.

devinea
devinea previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

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

looks good. Thanks @heimwege

…middleware-client/rta-duplicate-id-when-navigating-from-launchpad

# Conflicts:
#	packages/preview-middleware-client/eslint.config.js
#	packages/preview-middleware-client/src/flp/init.ts
@heimwege heimwege dismissed stale reviews from devinea, ytpo-lyne, and nikmace via 85b5cf2 March 30, 2026 22:31
@heimwege heimwege requested a review from a team as a code owner March 30, 2026 22:39
@heimwege
Copy link
Copy Markdown
Contributor Author

heimwege commented Mar 30, 2026

@ytpo-lyne @nikmace @devinea I had to resolve merge conflicts. please re-review

@devinea additionally I added es2020 globals to eslint-plugin-fiori-tools to support e.g. globalThis and added the @sap-ux/create convert command to the readme.

@heimwege heimwege added the eslint-plugin-fiori-tools @sap-ux/eslint-plugin-fiori-tools label Mar 30, 2026
ytpo-lyne
ytpo-lyne previously approved these changes Mar 31, 2026
…middleware-client/rta-duplicate-id-when-navigating-from-launchpad

# Conflicts:
#	packages/eslint-plugin-fiori-tools/README.md
Copy link
Copy Markdown
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

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

re-approving

Copy link
Copy Markdown
Contributor

@nikmace nikmace left a comment

Choose a reason for hiding this comment

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

Re-approving ✅

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

@heimwege heimwege merged commit 0153757 into main Apr 1, 2026
24 of 25 checks passed
@heimwege heimwege deleted the fix/preview-middleware-client/rta-duplicate-id-when-navigating-from-launchpad branch April 1, 2026 13:50
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.

4 participants