test(editor): keep-alive paths, neutral place visibility
Place visibility context moves to lib/placeVisibility.ts so the catalogue
no longer imports from components/editor. Adds tests: selection survival,
unmeasured hint round trip, keyboard tab move and « Aller à » with a field
focused, replace-tracing kept, announcements. Parse-sharing test uses
object identity. Early exits are two statements; shortcut comment on the
parse cache.
R-24:
- editor-equine.spec.ts:118, editor-geometry.spec.ts:376,
editor-recovery.spec.ts:39, editor-signout.spec.ts:26: page.getByLabel
('Nom (FR)') -> place(page, 'general').getByLabel(...)
- editor-shell.spec.ts: toHaveCount(0) on the visible query -> count 1
on the raw selector and toBeHidden()
- editor-keep-alive.test.tsx: JSON.parse stack-trace count -> same
object reference across places
This commit is contained in:
1 parent
6689827a8d
commit
79a09f8b25
12 files changed
+192
-46
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { usePlaceVisible } from '@/components/editor/KeptPlace'
|
||||
import { usePlaceVisible } from '@/lib/placeVisibility'
|
||||
import Button from '@/components/ui/Button'
|
||||
import Notice from '@/components/ui/Notice'
|
||||
import { coreRuntime, useCoreStopped } from '@/core/runtime'
|
||||
@@ -77,7 +77,10 @@ export default function CatalogueCanvas({
|
||||
const element = host.current
|
||||
if (!element) return
|
||||
// One composed copy of a view in the page (kept places): the ids repeat otherwise.
|
||||
if (!visible) return element.replaceChildren()
|
||||
if (!visible) {
|
||||
element.replaceChildren()
|
||||
return
|
||||
}
|
||||
const build = buildView(preview, viewId)
|
||||
setFailure(build.ok ? null : build.failure)
|
||||
element.replaceChildren(...(build.ok ? [build.svg] : []))
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
type HTMLAttributes,
|
||||
type ReactNode,
|
||||
} from 'react'
|
||||
|
||||
const PlaceVisibleContext = createContext(true)
|
||||
|
||||
/**
|
||||
* Whether the place around this component is shown: every enclosing `KeptPlace` is
|
||||
* visible. Outside any `KeptPlace` (the catalogue pages) it is true.
|
||||
*/
|
||||
export function usePlaceVisible(): boolean {
|
||||
return useContext(PlaceVisibleContext)
|
||||
}
|
||||
import type { HTMLAttributes, ReactNode } from 'react'
|
||||
import { PlaceVisibleContext, usePlaceVisible } from '@/lib/placeVisibility'
|
||||
|
||||
interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||
/** The `data-place` name; omitted for a wrapper that only nests places (tab panel). */
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState, type RefObject } from 'react'
|
||||
import type { ViewBox } from '@faunosteo/core-wasm/types'
|
||||
import Notice from '@/components/ui/Notice'
|
||||
import { buildView } from '@/components/catalogue/CatalogueCanvas'
|
||||
import { usePlaceVisible } from '@/components/editor/KeptPlace'
|
||||
import { usePlaceVisible } from '@/lib/placeVisibility'
|
||||
import { useEditorStore } from '@/editor/state/editorStore'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
@@ -24,7 +24,10 @@ function useParentFrame(
|
||||
const element = host.current
|
||||
if (!element || !preview) return
|
||||
// One composed copy of a view in the page: the ids repeat otherwise.
|
||||
if (!visible) return element.replaceChildren()
|
||||
if (!visible) {
|
||||
element.replaceChildren()
|
||||
return
|
||||
}
|
||||
const built = buildView(preview, parentId)
|
||||
element.replaceChildren(...(built.ok ? [built.svg] : []))
|
||||
setFrame(
|
||||
|
||||
Reference in new issue
Block a user