Skip to content

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

Merged
heimwege merged 13 commits into
mainfrom
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 into
mainfrom
fix/preview-middleware-client/rta-duplicate-id-when-navigating-from-launchpad

Conversation

@heimwege

@heimwege heimwege commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

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

changeset-bot Bot commented Mar 25, 2026

Copy link
Copy Markdown

🦋 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

@nikmace nikmace left a comment

Copy link
Copy Markdown
Contributor

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

@ytpo-lyne ytpo-lyne left a comment

Copy link
Copy Markdown
Contributor

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

@devinea devinea left a comment

Copy link
Copy Markdown
Contributor

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

heimwege commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

@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

@devinea devinea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

re-approving

@nikmace nikmace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-approving ✅

@sonarqubecloud

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

@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
eouin added a commit that referenced this pull request Apr 7, 2026
…upport-custom-fields-building-block

* 'main' of github.com:SAP/open-ux-tools: (84 commits)
  chore: apply latest changesets
  fix: align mta and package.json changes (#3630)
  chore: apply latest changesets
  fix(deploy-tooling): normalize package name to uppercase in ui5-deploy task flow (#4491)
  chore: apply latest changesets
  feat: Change `backend-proxy-middleware-cf` to use `approuter` instead of token exchange (#4160)
  chore: apply latest changesets
  Fix(preview-middleware-client): rta causing duplicate ID when navigating from launchpad (#4465)
  chore: apply latest changesets
  fix(project-access): guard against undefined URL in uniformUrl (#4498)
  chore: apply latest changesets
  fix(ui-components): add inline code styling for VS Code webview (#4501)
  chore: apply latest changesets
  fix(ui5-test-writer): correctly create OP header form field identifier (#4489)
  chore: apply latest changesets
  feat: Adjust FLP configuration wizard for CF scenario (#4455)
  chore: apply latest changesets
  fix: adjust min height for buttons after latest fount ui update (#4499)
  fix: int test (#4473)
  chore: apply latest changesets
  ...
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