@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.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 = container.querySelectorAll(
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
- for (const el of Array.from(candidates)) {
19385
- if (el.readOnly || el.disabled) continue;
19386
- el.focus();
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) => {