@ipxjs/refract 0.14.0 → 0.16.0
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/package.json +1 -1
- package/src/refract/dom.ts +8 -0
- package/src/refract/features/hooks.ts +10 -0
package/package.json
CHANGED
package/src/refract/dom.ts
CHANGED
|
@@ -164,6 +164,14 @@ export function applyProps(
|
|
|
164
164
|
el.removeEventListener(event, getEventListener(oldProps[key]));
|
|
165
165
|
}
|
|
166
166
|
el.addEventListener(event, getEventListener(newProps[key]));
|
|
167
|
+
} else if (
|
|
168
|
+
!isSvgElement &&
|
|
169
|
+
(key === "value" || key === "checked") &&
|
|
170
|
+
(el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT")
|
|
171
|
+
) {
|
|
172
|
+
// Use DOM property for form element values (like React does), so that
|
|
173
|
+
// controlled inputs update their displayed value correctly.
|
|
174
|
+
(el as any)[key] = newProps[key] ?? (key === "checked" ? false : "");
|
|
167
175
|
} else {
|
|
168
176
|
const value = newProps[key];
|
|
169
177
|
const attr = normalizeAttributeName(key, isSvgElement);
|
|
@@ -37,6 +37,16 @@ export function useState<T>(initial: T | (() => T)): [T, (value: T | ((prev: T)
|
|
|
37
37
|
if (!hook._setter) {
|
|
38
38
|
hook._setter = (value: T | ((prev: T) => T)) => {
|
|
39
39
|
if (!hook._fiber) return;
|
|
40
|
+
// Bail out for same-value direct updates with no pending queue (matches React behavior).
|
|
41
|
+
// This prevents infinite loops when setState(sameValue) is called in effects —
|
|
42
|
+
// e.g. MUI FormControl/InputBase calling setAdornedStart(false) repeatedly.
|
|
43
|
+
if (
|
|
44
|
+
typeof value !== "function" &&
|
|
45
|
+
Object.is(value, hook.state) &&
|
|
46
|
+
(!hook.queue || (hook.queue as unknown[]).length === 0)
|
|
47
|
+
) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
40
50
|
const action = typeof value === "function"
|
|
41
51
|
? value as (prev: T) => T
|
|
42
52
|
: () => value;
|