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