fix(editor): repair dialog limits, pending drafts block apply, dialog wording
This commit is contained in:
1 parent
3776a33b79
commit
9c21fd3f86
8 files changed
+197
-52
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import FormField, { fieldDescribedBy } from '@/components/ui/FormField'
|
||||
import Button from '@/components/ui/Button'
|
||||
import Input from '@/components/ui/Input'
|
||||
@@ -26,6 +26,8 @@ export interface GeometryGroupProps {
|
||||
onApply: (geometry: EditableGeometry) => ApplyResult
|
||||
/** Fields shown as text: read-only mode or an unmeasured view. */
|
||||
locked: boolean
|
||||
/** Told whenever typed values differ from `geometry` (shown « non appliqué »). */
|
||||
onPending?: (pending: boolean) => void
|
||||
}
|
||||
|
||||
type Fields = GroupFields
|
||||
@@ -62,6 +64,13 @@ function useGroupState(geometry: EditableGeometry) {
|
||||
*/
|
||||
export default function GeometryGroup(props: GeometryGroupProps) {
|
||||
const { state, set } = useGroupState(props.geometry)
|
||||
const pending = changedFieldNames(state.draft, props.geometry).size > 0
|
||||
const report = useRef(props.onPending)
|
||||
report.current = props.onPending
|
||||
useEffect(() => {
|
||||
report.current?.(pending)
|
||||
return () => report.current?.(false)
|
||||
}, [pending])
|
||||
const propose = (next: Fields) => {
|
||||
if (sameAsStored(next, props.geometry))
|
||||
return set({ draft: next, messages: [] })
|
||||
@@ -85,7 +94,7 @@ export default function GeometryGroup(props: GeometryGroupProps) {
|
||||
)
|
||||
}
|
||||
|
||||
interface BodyProps extends Omit<GeometryGroupProps, 'onApply'> {
|
||||
interface BodyProps extends Omit<GeometryGroupProps, 'onApply' | 'onPending'> {
|
||||
draft: Fields
|
||||
pending: Set<string>
|
||||
messages: string[]
|
||||
|
||||
Reference in new issue
Block a user