Skip to content

docs: hide demo-only helpers in the React examples - #6678

Open
peholmst wants to merge 2 commits into
mainfrom
claude/issue-2730-review-0aa8fb
Open

peholmst wants to merge 2 commits into
mainfrom
claude/issue-2730-review-0aa8fb

Conversation

@peholmst

@peholmst peholmst commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #2730.

The docs show the full source of each example with the hidden-source-line lines removed. Several React examples still showed code that only exists for the docs site, so copying them into an application gave unresolved imports or calls to functions the reader doesn't have. For example, the Confirm Dialog page still shows import confirmDialogBasicStyles from './confirm-dialog-basic-styles';.

The Lit variants already hid these helpers. This change brings the React variants in line:

  • Host styles. The style imports that only feed the hidden reactExample() call are now hidden (Confirm Dialog, Dialog, Login). The inline hostStyles in App Layout, Login and Rich Text Editor move to -styles.ts files with a hidden import. Prettier formats CSS inside css templates and would move per-line markers.
  • Navigation patches (App Layout, Side Nav, Breadcrumbs, Tooltip). The patch functions now accept null, so the examples pass them as a hidden callback ref, ref={patchSideNavNavigation} // hidden-source-line, instead of a visible useRef and useEffect. The bottom navbar example now forces the touch-optimized mode with a hidden style attribute, as the Flow variant does. Its old code also called _updateTouchOptimizedMode(), which App Layout doesn't have. The React example threw and rendered blank, also on the published docs.
  • Upload fake files. The files binding, the useComputed() call and the mock error response are hidden. The inline createFakeFiles() functions of the clear, start and retry button examples move to the upload-demo-mock-files modules, for Lit too.
  • Hidden imports that visible code used. Unhidden in Button Grid (Button), Context Menu best practices (useCallback) and the Lit Badge table (DataService).

Where the hidden attribute was the tag's only one, the line uses hidden-source-line-trim, so the tag renders as <Breadcrumbs> rather than <Breadcrumbs and > on separate lines. This follows the published Lit Upload example.

Left as they are: the shared sample data (DataService, generated types), and the placeholder content in Split Layout (MasterContent / DetailContent) and Dashboard (mock-widgets). Every framework variant uses these on purpose.

Checks

  • ESLint passes on all changed files, and TypeScript reports no errors in them.
  • A script that rebuilds the visible source of each changed example shows no remaining helper calls, refs or fake-file code. A second script finds no remaining "hidden import used in visible code" in frontend/demo.
  • I read the @lit/react and useMergedRefs sources: both call function refs with the element, and with null on unmount.
  • Loaded every changed React example from the PR preview:
    • They all render.
    • The Side Nav and Breadcrumbs links are patched.
    • Navbar link clicks in App Layout are prevented.
    • The Upload examples show their fake files, and Upload error messages answers with the mock 500 error.
    • The bottom navbar fix is in a later push than the preview I checked.

🤖 Generated with Claude Code

Several React examples showed code that only exists for the docs site,
so a reader who copied them got unresolved imports or calls to functions
they did not have:

- Style imports that only feed the hidden reactExample() call
  (Confirm Dialog, Dialog, Login) and inline host styles (App Layout,
  Login, Rich Text Editor), now in -styles.ts files with hidden imports.
- The navigation patches that keep links inside the example frame
  (App Layout, Side Nav, Breadcrumbs, Tooltip). The patch functions now
  accept null, so the examples pass them as a hidden callback ref instead
  of a visible useRef and useEffect.
- The fake upload files and the mock error response (Upload). The
  inline createFakeFiles() functions of the clear, start and retry
  button examples move to the mock-files modules, also for Lit.

Also unhides imports that visible code uses (Button Grid, Context Menu,
Badge).

Fixes #2730

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peholmst peholmst added the target/v25.3 Automatically cherry-pick to the v25.3 branch label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

This PR has been deployed for preview.

URL: https://docs-preview-pr-6678.fly.dev

Changed pages

Added content is highlighted in green; removed content is marked in red on each page.

Other changed files

  • frontend/demo/component/app-layout/app-layout-helper.ts (modified)
  • frontend/demo/component/app-layout/react/app-layout-height-full-styles.ts (added)
  • frontend/demo/component/breadcrumbs/breadcrumbs-helper.ts (modified)
  • frontend/demo/component/login/react/login-rich-content-styles.ts (added)
  • frontend/demo/component/richtexteditor/react/rich-text-editor-set-get-value-styles.ts (added)
  • frontend/demo/component/side-nav/react/side-nav-helper.ts (modified)
  • frontend/demo/component/side-nav/side-nav-helper.ts (modified)
  • frontend/demo/component/upload/react/upload-demo-mock-files.ts (modified)
  • frontend/demo/component/upload/upload-demo-mock-files.ts (modified)

Built from a2e3494

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the changes — left 1 comment.

Finding
⚠️ The new helper calls _updateTouchOptimizedMode(), which no longer exists in App Layout

@@ -22,35 +16,19 @@ const linkStyle = {
};

function Example() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This example does not render at all. The currently published example also doesn't work. The lit version works, though.

The React bottom navbar example called _updateTouchOptimizedMode(),
which App Layout does not have, so the example threw and rendered blank.
Setting --vaadin-app-layout-touch-optimized is enough: App Layout reads
it when it becomes ready. Set it in a hidden style attribute and drop
the enableTouchOptimizedMode() helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/v25.3 Automatically cherry-pick to the v25.3 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some Hilla component examples are not standalone

2 participants