pcm-shared-components 2.1.402 → 2.1.403
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.
|
@@ -213,11 +213,20 @@ export const AnimalVehicleDetailsEditor = props => {
|
|
|
213
213
|
//
|
|
214
214
|
// Re-runs whenever the wrapped set itself changes (not just when `fieldConfig` changes), because
|
|
215
215
|
// promoting one field to full width re-pairs its neighbors, which can occasionally make a
|
|
216
|
-
// DIFFERENT field's label newly wrap
|
|
217
|
-
//
|
|
218
|
-
//
|
|
216
|
+
// DIFFERENT field's label newly wrap at its new column width.
|
|
217
|
+
//
|
|
218
|
+
// Promotions must be a ONE-WAY RATCHET (seed from `prev`, only ever add) rather than recomputed
|
|
219
|
+
// from scratch each pass. A field promoted to full width almost always stops wrapping there --
|
|
220
|
+
// it just got 2x the space -- so measuring fresh every time would immediately demote it again,
|
|
221
|
+
// which shrinks it back to half width, which makes it wrap again, which re-promotes it... an
|
|
222
|
+
// infinite loop that used to hang the whole editor (every field whose label happened to wrap at
|
|
223
|
+
// half width but fit at full width triggered this on mount). Only dropping keys that are no
|
|
224
|
+
// longer in `fieldConfig` at all keeps a stale promotion from leaking across an entirely
|
|
225
|
+
// different field set. The state setter still bails out (no re-render) the moment a pass finds
|
|
226
|
+
// no change, so this converges in at most `fieldConfig.length` passes.
|
|
219
227
|
useLayoutEffect(() => {
|
|
220
|
-
const
|
|
228
|
+
const liveKeys = new Set(fieldConfig.map(f => f.key));
|
|
229
|
+
const nextWrapped = new Set([...wrappedKeys].filter(k => liveKeys.has(k)));
|
|
221
230
|
labelRefs.current.forEach((el, fieldKey) => {
|
|
222
231
|
if (!el) return;
|
|
223
232
|
const lineHeight = parseFloat(getComputedStyle(el).lineHeight) || 0;
|