@mittwald/flow-react-components 1.6.0-next.19 → 1.6.0-next.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -352,8 +352,8 @@ item 4 in the
352
352
  - **Tests that pass without the fix.** Revert the fix and watch the test fail
353
353
  before committing it. If it cannot fail, it guards nothing; say in the PR how
354
354
  you verified the fix instead. The `optimizeDeps` entry under
355
- [Common failures](https://github.com/mittwald/flow/blob/main/AGENTS.md#common-failures)
356
- in the root AGENTS.md shows one way a test passes in both directions.
355
+ [Common failures](#common-failures) below shows one way a test passes in both
356
+ directions.
357
357
 
358
358
  Run: `pnpm nx test:unit components`,
359
359
  `pnpm nx test:browser components --browser.name=webkit`. The browser targets
@@ -660,3 +660,102 @@ Easy-to-miss conventions not spelled out above. Full details and examples in
660
660
  - **Universal exports are deliberately explicit** — remote-safe values and their
661
661
  types are curated in `flr-universal.ts` independently of the main public
662
662
  surface; adding to `public.ts` does not add them there.
663
+
664
+ ## Common failures
665
+
666
+ Symptom → cause → fix for authoring components. Repo-wide ones are in the
667
+ [root AGENTS.md](https://github.com/mittwald/flow/blob/main/AGENTS.md#common-failures).
668
+
669
+ - **Symptom:** `test:compile` fails on a new component — the
670
+ `flowComponent("X", …)` name/props type isn't assignable
671
+
672
+ **Cause:** `flowComponent` names are typed as `keyof` a hand-maintained props
673
+ registry
674
+
675
+ **Fix:** Register the props type in
676
+ `packages/components/src/components/propTypes/index.ts` (see
677
+ [The flowComponent factory](#the-flowcomponent-factory))
678
+
679
+ - **Symptom:** `test:compile` fails in unrelated shared code with
680
+ **`Property 'children' does not exist on type 'Partial<XProps>'`** right after
681
+ you registered a new component
682
+
683
+ **Cause:** `dynamic()` and other shared helpers are typed over the **union of
684
+ every** registered props type, so code reading `p.children` breaks as soon as
685
+ one registered component has no `children` (`Field.tsx`,
686
+ `flowComponent.browser.test.tsx`)
687
+
688
+ **Fix:** Declare `children?: never` on the new props type. It keeps the union
689
+ accessible and documents that the component takes no children — do **not** add
690
+ a real `children` slot you then ignore
691
+
692
+ - **Symptom:** A `ReactElement`-valued prop renders fine in the visual suite's
693
+ **Remote** environment but kills a real remote connection with
694
+ **`DataCloneError: Symbol(react.transitional.element) could not be cloned`**
695
+ (the host then shows `Remote rendering failed: Timeout reached`)
696
+
697
+ **Cause:** The prop was generated as a **remote property**, and properties
698
+ travel through `postMessage`/structured clone, which cannot carry a React
699
+ element. `remote-dom-react` turns an element-valued prop into a slotted child
700
+ _only_ when the element declares it as a slot
701
+ (`Element.remoteSlotDefinitions.has(prop)`), and the generator declares a slot
702
+ only for props typed exactly `ReactNode` or listed in `@flr-slot-props`
703
+ (`dev/remote-components-generator/lib/propClassifiers.ts`)
704
+
705
+ **Fix:** Add `@flr-slot-props <propA>, <propB>` to the component's JSDoc and
706
+ regenerate — the prop then arrives as a slotted child and any React subtree
707
+ works, including a raw `<svg>` or a Tabler icon. The visual suite's **Remote**
708
+ environment does serialize (a MessageChannel through
709
+ `FlowThreadSerialization`), but `FlowThreadSerialization` drops React values
710
+ to `null` with a `console.error` before `postMessage` ever sees them — so the
711
+ suite renders a component missing the prop, not the `DataCloneError`. Read the
712
+ console, or verify in `apps/remote-dom-demo` over the iframe connection
713
+
714
+ - **Symptom:** A function prop works locally but its result is garbage remotely
715
+ — a formatter renders `[object Promise]`, a predicate is always truthy
716
+
717
+ **Cause:** The prop is a **remote property**, and
718
+ `FlowThreadSerialization.isSerializableByBase` accepts any function, so
719
+ `@quilted/threads` sends it as a proxy. Calling a proxy is a round trip, so
720
+ the host gets a **Promise**, never the value. Only `on*` events are safe by
721
+ construction — they are fire-and-forget
722
+
723
+ **Fix:** Either type the prop's return as `Promise<T> | T` and have the host
724
+ `await` it (`ChartTooltip`'s formatters do), or drop it from the remote
725
+ surface with `@flr-ignore-props` (`XAxis`/`YAxis` `tickFormatter` do) and
726
+ regenerate. `checkSerializableProps` now fails generation on new ones; the
727
+ pre-existing set is listed in `acknowledgedValueReturningProps`
728
+
729
+ - **Symptom:** A `components` browser test keeps **passing** after you change
730
+ `packages/icons` — including a test written to fail on exactly that change.
731
+ The build is not the problem: `pnpm nx build icons` runs `tsc` and `dist`
732
+ holds the new code
733
+
734
+ **Cause:** `packages/components/vite.config.ts` lists `@mittwald/flow-icons`
735
+ in `optimizeDeps.include`, so vite pre-bundles it. The prebundle is keyed on
736
+ the lockfile and the config, not on the contents of a linked workspace
737
+ package's `dist` — so a rebuilt `dist` does not invalidate it and the test
738
+ keeps loading the old bundle
739
+
740
+ **Fix:** Delete `packages/components/node_modules/.vite*` after rebuilding.
741
+ And confirm a new regression test actually fails without its fix: this one
742
+ passed in both directions, which is the only symptom you get
743
+
744
+ - **Symptom:** `stylelint` fails with **`flow/no-unknown-global-flow-class`** —
745
+ a `:global(.flow--…)` name resolves to nothing
746
+
747
+ **Cause:** The class-name generator
748
+ (`packages/components/dev/vite/cssModuleClassNameGenerator.ts`) **drops the
749
+ suffix when it equals the component name**, so `ColumnLayout`'s
750
+ `.columnLayout` compiles to `flow--column-layout`, not
751
+ `flow--column-layout--column-layout`. The names cannot be derived by hand, and
752
+ a component that moves leaves every reference to it dead
753
+
754
+ **Fix:** Copy the name from the component's committed `*.module.d.scss.ts` —
755
+ that is what the rule checks against — or take the rule's "Did you mean"
756
+ suggestion. Just added the class? Regenerate the stubs first:
757
+ `pnpm nx build:scss-types components`. The same applies to ESLint's
758
+ `flow/no-unknown-flow-class`, which checks hardcoded `flow--…` strings in
759
+ TS/TSX (#3095). Before the rule (#3091) this class of bug failed completely
760
+ silently: no build error, no console warning, and the docs site and Storybook
761
+ kept rendering