Skip to content

feat: signal async CMS nav ready via flag and event#1304

Open
wesleyboar wants to merge 2 commits into
feat/custom-scriptsfrom
feat/cms-nav-ready-event
Open

feat: signal async CMS nav ready via flag and event#1304
wesleyboar wants to merge 2 commits into
feat/custom-scriptsfrom
feat/cms-nav-ready-event

Conversation

@wesleyboar

@wesleyboar wesleyboar commented May 26, 2026

Copy link
Copy Markdown
Member

Overview

After the CMS nav HTML is injected and post-processed, set a data- attr flag and send a CustomEvent. This lets scripts in other repos safely defer link initialization until the async nav is populated.

The custom script loaded via #1303 needs to modify a CMS nav link — but on Portal the nav is injected asynchronously, so the link doesn't exist at script load time. This PR adds the signal that lets that script wait safely.

Related

Changes

  • added NAV_READY_ATTR and NAV_READY_EVENT const's
  • added data-nav-ready flag and cms-nav:ready event dispatch

Testing

  1. In DevTools console, run document.getElementById('s-cms-nav').dataset.navReady — should return 'true' once the nav is populated.
  2. Test fix(ptdatax): new tab link on Portal requires CMS nav ready Core-CMS-Custom#538.
  3. Load a Portal page and confirm the CMS nav renders normally.
  4. Confirm no regressions i.e. these still work:
    1. On portal, active link is highlighted.
    2. On CMS page, Bootstrap 4→5 toggle shim still work.

UI

1. Console Test
Console Test
2. & 3. Render Normal & Link Set to Open in New Tab
Link Set to Open in New Tab
4.a. flagLinkActive Still Works
flagLinkActive Still Works
4.b. Bootstrap Shim Still Works
Bootstrap Tweak Still Works

Notes

Note

Gray links in CMS Nav on Portal is known, recent, unrelated bug.


Made with Cursor

After nav HTML is injected and post-processed, set `data-nav-ready`
on `#s-cms-nav` and dispatch `cms-nav:ready` so dependent scripts can
safely initialize links that live inside the async-loaded nav.

Co-authored-by: Cursor <cursoragent@cursor.com>
@wesleyboar wesleyboar changed the title feat(nav): signal async CMS nav ready via flag and event feat: signal async CMS nav ready via flag and event May 26, 2026
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.09%. Comparing base (bc7c1ce) to head (16dc201).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           feat/custom-scripts    #1304   +/-   ##
====================================================
  Coverage                64.09%   64.09%           
====================================================
  Files                      461      461           
  Lines                    13794    13794           
  Branches                  2750     2745    -5     
====================================================
  Hits                      8841     8841           
  Misses                    4604     4604           
  Partials                   349      349           
Flag Coverage Δ
javascript 67.10% <ø> (ø)
unittests 60.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wesleyboar
wesleyboar marked this pull request as draft May 26, 2026 21:13
wesleyboar added a commit to TACC/Core-CMS-Custom that referenced this pull request May 26, 2026
## Overview

Wrap `findLinksAndSetTargets`, and defer until CMS nav signals it is
ready.

<details>

`open-certain-links-in-new-tab.js` was calling `findLinksAndSetTargets`
immediately at load time. On Portal pages the CMS nav is injected
asynchronously, so the target links don't exist yet.

</details>

## Related

- requires TACC/Core-Portal#1304

## Changes

- **refactored** link query and `findLinksAndSetTargets` call into
`initLinks` function

## Testing

1. **On CMS page**: Confirm `internal-docs` links **still** open in a
new tab.
2. **On Portal**: Confirm `internal-docs` links **newly** open in a new
tab.

## UI


https://github.com/user-attachments/assets/96879167-070d-4b63-84e0-bfe5a6295542


https://github.com/user-attachments/assets/36309943-33d7-4272-928c-d623ae2efa7f

---

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@wesleyboar
wesleyboar marked this pull request as ready for review May 26, 2026 22:46
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.

1 participant