Fix(preview-middleware-client): rta causing duplicate ID when navigating from launchpad - #4465
Conversation
🦋 Changeset detectedLatest commit: 1b26214 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
|
@schiwekM FYI |
nikmace
left a comment
There was a problem hiding this comment.
Changes look good
Changeset is OK
Coverage is good
Did not test manually
…id-when-navigating-from-launchpad
ytpo-lyne
left a comment
There was a problem hiding this comment.
- code changes for RTA endpoints look good
- changeset present
- excellent coverage
- did not test manually
Approving.
…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
|
@ytpo-lyne @nikmace @devinea I had to resolve merge conflicts. please re-review @devinea additionally I added |
…id-when-navigating-from-launchpad
…id-when-navigating-from-launchpad
…middleware-client/rta-duplicate-id-when-navigating-from-launchpad # Conflicts: # packages/eslint-plugin-fiori-tools/README.md
…id-when-navigating-from-launchpad
|
…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 ...



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].