Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(client): warn about null roots of jQuery-mounted components
Elian Doran0c1ab257c863
diff --git a/.claude/skills/building-client-ui/SKILL.md b/.claude/skills/building-client-ui/SKILL.mdindex d3e1d97190..37d61ef5c6 100644--- a/.claude/skills/building-client-ui/SKILL.md+++ b/.claude/skills/building-client-ui/SKILL.md@@ -263,6 +263,7 @@ use parameter defaults.- **Bootstrap utility classes or inline static styles on `Form*` components** — use the sibling per-component `.css` scoped under a root class.- **A scroller inside a padded `CardSection`** — scrolled content is clipped short of the card's border. Use `noPadding` on the section and put `--card-padding-block`/`--card-padding-inline` on the scrolling element (see `Card` in the catalogue).- **Hand-rolled overlay buttons** — `tn-overlay-*` classes at a call site instead of `OverlayControlGroup` / `OverlayControlButton`.+- **Returning `null` from a component mounted with `.child(<X />)`** — `ReactWrappedWidget.doRender()` adopts the elements the first render produces as `$widget`, so a component that first renders nothing never reaches the page, and its later renders go into a detached fragment. Always render a root element and put the condition inside it (`<div className="x">{note && <Button … />}</div>`), or hide it with CSS. That root also gets the widget's `component` class, which `style.css` gives `contain: size`: in a flex row it collapses to 0×0 and its content overflows below it, so a wrapper sized by its content needs `.component.x { contain: none; }` (as `toggle_sidebar_button.css` and `NoteBadges.css` do).- **Copying the jQuery lifecycle** (`doRenderBody` / `refreshWithNote` / `this.$widget`) into new `.tsx` — use `useLegacyWidget` only to embed an existing widget.- **A `useEffect` cleanup that must run during the unmount** — it runs after paint; reporting to a host or reading a child instance belongs in a `useLayoutEffect` cleanup (see "Preact 11 conventions").- **Importing core names through `preact/compat`** — `createPortal`, hooks and types come from `preact` / `preact/hooks`; compat is for `memo`, `lazy`, `Suspense`, `flushSync`, `useSyncExternalStore`.