Skip to content

Commit e2d140e

Browse files
committed
Fix dual-read mismatches: alias timing, key-image re-render, deepEqual null
1 parent 94cf1e2 commit e2d140e

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

apps/roam/src/components/settings/DiscourseNodeCanvasSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ const DiscourseNodeCanvasSettings = ({
142142
settingKeys={[DISCOURSE_NODE_KEYS.canvasSettings, CANVAS_KEYS.keyImage]}
143143
initialValue={isKeyImage}
144144
onChange={(checked) => {
145-
setIsKeyImage(checked);
146145
if (checked && !keyImageOption) setKeyImageOption("first-image");
147146
void setInputSetting({
148147
blockUid: uid,
149148
key: "key-image",
150149
value: checked ? "true" : "false",
151150
});
151+
setTimeout(() => setIsKeyImage(checked), 100);
152152
}}
153153
/>
154154
<RadioGroup

apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ const BaseTextPanel = ({
145145
debounceRef.current = window.setTimeout(() => {
146146
if (errorRef.current) return;
147147
syncToBlock?.(newValue);
148-
refreshConfigTree();
149-
setter(settingKeys, newValue);
148+
setTimeout(() => {
149+
refreshConfigTree();
150+
setter(settingKeys, newValue);
151+
}, 100);
150152
}, DEBOUNCE_MS);
151153
};
152154

@@ -232,9 +234,6 @@ const BaseFlagPanel = ({
232234
await syncFlagToBlock(checked);
233235
refreshConfigTree();
234236
setter(settingKeys, checked);
235-
// Delay onChange to let the async Roam block.update flush before
236-
// the re-render reads block props via dual-read comparison.
237-
// TODO(ENG-1471): remove with dual-read cleanup
238237
setTimeout(() => onChange?.(checked), 100);
239238
};
240239

apps/roam/src/components/settings/utils/accessors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const isRecord = (value: unknown): value is Record<string, unknown> =>
4747

4848
const deepEqual = (a: unknown, b: unknown): boolean => {
4949
if (a === b) return true;
50-
const isEmpty = (v: unknown) => v === undefined || v === "" || v === false;
50+
const isEmpty = (v: unknown) =>
51+
v === undefined || v === null || v === "" || v === false;
5152
if (isEmpty(a) && isEmpty(b)) return true;
5253
if (a == null || b == null) return a === b;
5354
if (Array.isArray(a) && Array.isArray(b)) {

0 commit comments

Comments
 (0)