Skip to content

feat: render no <style> elements, for CSP without unsafe-inline - #3318

Merged
interactivellama merged 8 commits into
feat/v11-llm-4-deprecated-lintfrom
feat/v11-asks-2-csp
Nov 24, 2026
Merged

interactivellama merged 8 commits into
feat/v11-llm-4-deprecated-lintfrom
feat/v11-asks-2-csp

Conversation

@interactivellama

@interactivellama interactivellama commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of the v11 merge train, stack 3 "GA requirements": asks-2 CSP → SLDS 2 CSS fixes → asks-4 perf → perf improvements → per-component CSS (experimental, last).

Additional description

MenuDropdown with tooltipMenuItem, Tooltip with hasAnchoredNubbin, and File with moreActionsDropdo <img width="1124" height="548" alt="files-no-title-with-actions" src="https://github.com/user-attachments/assets/7c160e9a-a5ad-42fb-937d-2908ea7824c1" /> wn rendered <style> elements. A Content-Security-Policy without 'unsafe-inline' in style-src blocks those. Each now uses SLDS markup instead, with no extra stylesheet:

Tooltip with hasAnchoredNubbin
tooltip-anchored-nubbin

MenuDropdown with tooltipMenuItem
menudropdown-with-tooltips

File with moreActionsDropdown
files-with-actions

  • menu-list: a tooltip menu item's link is the li's direct child, so SLDS's .slds-dropdown__item > a rules apply. The tooltip renders next to the link, opens on hover and focus, and points at the link with onRequestTargetElement. Adds a MenuDropdown WithTooltips story.
  • tooltip: the internal Dialog takes isNubbinHidden. It keeps the nubbin offset but leaves out the slds-nubbin_* class, so there is nothing to hide.
  • files: the more-actions trigger adds SLDS's slds-button_last. File.injectMoreActionsStyles() is public, so it stays, deprecated, and returns null. Adds a Files WithActions story.
  • test: every story is mounted into jsdom and must not render a <style> element. This covers open menus and portals, which the SSR snapshots miss.
  • Changes the default the theme in Storybook to Cosmos from Lightning Blue

This PR has no breaking changes. The tooltip menu item's DOM changes, but its roles and accessible names don't.


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request.

Green gate — all of these must pass locally (CI runs the same):

  • npm run lint passes with 0 errors (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
  • npm run typecheck is clean (tsc --noEmit).
  • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
  • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
  • Added/updated Vitest + React Testing Library tests for the change (template: components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a *.browser.test.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: npm run storybook → http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).
  • Story/example code uses the component's real prop API (e.g. slots like content / visualPickerFigure, render props like renderItem, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
  • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@salesforce/design-system-react/components/<name> and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change → feat!:/BREAKING CHANGE: and a major version bump.

@interactivellama
interactivellama removed this pull request from stack #3321 November 16, 2026 09:08
@interactivellama
interactivellama removed this pull request from stack #3329 November 16, 2026 09:12
@interactivellama
interactivellama removed this pull request from stack #3330 November 16, 2026 09:19
@interactivellama
interactivellama removed this pull request from stack #3331 November 16, 2026 09:26
@interactivellama
interactivellama removed this pull request from stack #3332 November 16, 2026 22:31
@interactivellama interactivellama added this to the 11.0.0-rc.1 milestone Nov 18, 2026
@interactivellama
interactivellama changed the base branch from master to feat/v11-llm-4-deprecated-lint November 18, 2026 23:29
@interactivellama
interactivellama removed this pull request from stack #3344 November 19, 2026 04:42
@interactivellama
interactivellama removed this pull request from stack #3346 November 19, 2026 22:05
@interactivellama
interactivellama removed this pull request from stack #3348 November 20, 2026 00:23
@interactivellama
interactivellama force-pushed the feat/v11-asks-2-csp branch 3 times, most recently from b94f3d9 to 8778f47 Compare November 20, 2026 23:43
With tooltipMenuItem, List rendered a <style> element, which a
Content-Security-Policy without 'unsafe-inline' for style-src blocks. It
restyled links that the Tooltip's trigger wrapper had moved out of
SLDS's `.slds-dropdown__item > a` rules. The item now renders the
tooltip next to the link instead of around it, opens it on hover and
focus, and points it at the link with onRequestTargetElement, so SLDS
styles the link like any other item and no extra CSS is needed. A
template's own isOpen still controls the tooltip. Adds a MenuDropdown
WithTooltips story.
With hasAnchoredNubbin, Tooltip rendered a per-id <style> element to hide
the dialog's nubbin, which a Content-Security-Policy without
'unsafe-inline' for style-src blocks. The internal Dialog now takes
isNubbinHidden: it keeps the nubbin offset so the tooltip doesn't move,
but leaves out the slds-nubbin_* class, so there is nothing to hide.
File rendered injectMoreActionsStyles()'s <style> element whenever
moreActionsDropdown was set, which a Content-Security-Policy without
'unsafe-inline' for style-src blocks. The trigger wraps the button, so
SLDS's button-group :first-child rule rounded its left corners.
slds-button_last is SLDS's own class for a dropdown at the end of a
button group and rounds the right ones. The a::before/::after background
reset overrode nothing in SLDS 1 or 2 and is dropped.

File.injectMoreActionsStyles() is public, so it stays, deprecated, and
returns null. Adds a Files WithActions story.
Mount every story into jsdom and check that the document has no <style>
elements, which a Content-Security-Policy without 'unsafe-inline' for
style-src blocks. This covers open menus and portals, which the
ReactDOMServer snapshots miss.
CHANGELOG: the three components that no longer render <style> (Changed)
and File.injectMoreActionsStyles (Deprecated).
no-style-elements mounts every story, which replays their deprecation and
Modal app-element warnings, and the tooltip browser test passed its trigger
as the deprecated children. The console guard from #3322 counts both. Mock
console in the story sweep, restoring it after cleanup since unmounting a
Modal warns too, and pass the tooltip trigger through trigger.
@interactivellama
interactivellama marked this pull request as ready for review November 23, 2026 07:18
@interactivellama
interactivellama removed this pull request from stack #3359 November 23, 2026 07:57
@interactivellama
interactivellama removed this pull request from stack #3360 November 23, 2026 23:53
@interactivellama
interactivellama merged commit 4026012 into master Nov 24, 2026
7 checks passed
@interactivellama
interactivellama deleted the feat/v11-asks-2-csp branch November 24, 2026 21:45
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