@mathscan/math-exercise-engine 1.2.1 → 1.2.2
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/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19376,16 +19376,14 @@ const ExerciseRenderer = forwardRef(({
|
|
|
19376
19376
|
setResetKey((k) => k + 1);
|
|
19377
19377
|
},
|
|
19378
19378
|
focusFirstInput: () => {
|
|
19379
|
-
const container = rootRef.current;
|
|
19379
|
+
const container = rootRef.current ?? document.querySelector(".math-exercise-renderer");
|
|
19380
19380
|
if (!container) return;
|
|
19381
|
-
const candidates =
|
|
19382
|
-
'input[type="text"], input[type="number"], textarea, select'
|
|
19381
|
+
const candidates = Array.from(
|
|
19382
|
+
container.querySelectorAll('input[type="text"], input[type="number"], textarea, select')
|
|
19383
19383
|
);
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
return;
|
|
19388
|
-
}
|
|
19384
|
+
const canTakeInput = (el) => !el.readOnly && !el.disabled;
|
|
19385
|
+
const target = candidates.find(canTakeInput) ?? (locked ? void 0 : candidates[0]);
|
|
19386
|
+
target?.focus();
|
|
19389
19387
|
}
|
|
19390
19388
|
}), [json, values, onSubmit, playSound, locked]);
|
|
19391
19389
|
const handleChange = (widgetId, value, fromDrop = false, sourceOptionId) => {
|