Repository navigation
Conversation
mo.ui.text(kind="email") and kind="url" validate the value left on blur, but with debounce=True (the default) the blurred value was never recorded, so an invalid address never got the red border. With debounce=True the committed value only changes on blur or Enter, so validate it directly.
|
All contributors have signed the CLA ✍️ ✅ |
| const valueToValidate = valueOnBlur == null ? value : valueOnBlur; | ||
| // With debounce=true, the value only changes on blur or Enter. | ||
| const valueToValidate = | ||
| props.debounce === true ? value : (valueOnBlur ?? value); |
There was a problem hiding this comment.
🤖 Automated comment by Shahmir's Code Review agent running Claude Sonnet 5.5 on Claude Code
?? value fallback is unreachable
valueOnBlur is a string (useState(props.value)) and is never nullish, so ?? value never runs. The old == null check was equally dead, but since this line is being rewritten it could say what actually happens: props.debounce === true ? value : valueOnBlur.
marimo/frontend/src/plugins/impl/TextInputPlugin.tsx
Lines 103 to 106 in c7ec961
| const { rerender } = render(plugin.render(props)); | ||
| const control = screen.getByLabelText("Email"); | ||
| const committed = plugin.render({ ...props, value: "not-an-email" }); | ||
| if (debounce === false) { |
There was a problem hiding this comment.
🤖 Automated comment by Shahmir's Code Review agent running Claude Sonnet 5.5 on Claude Code
Test branches on the mode and misses the Enter / recovery paths
The if (debounce === false) branch plus the second rerender(committed) make this harder to read than it needs to be, and only debounce=true was broken (false and 200 pass on main). Splitting the true case out would simplify it. Two cases from the PR's manual checks aren't covered: committing with Enter, and an invalid value corrected back to valid clearing the red border.
marimo/frontend/src/plugins/impl/__test__/text-labels.test.tsx
Lines 129 to 132 in c7ec961
…ce=true Validate the committed value directly for debounce=true (the old nullish fallback could not run) and replace the mode-branching test with three plain debounce=true cases: committed on blur, committed with Enter, and a corrected value clearing the error.
This pull request was authored by a coding agent.
📝 Summary
mo.ui.text(kind="email")andkind="url"outline an invalid value in red once you leave the field. With the defaultdebounce=Truethat never happened: the plugin validates the value it records on blur, but in that mode it rendersOnBlurredInput, which sets its ownonBlurand is not given the plugin's, so the recorded value stayed at the initial one and the field always counted as valid.debounce=Falseand a numericdebouncewere fine.With
debounce=Truethe committed value only changes on blur or Enter, so the plugin now validates that value directly. A one-line change inTextInputPlugin.tsx.flowchart TD A[Type not-an-email into mo.ui.text kind email and leave the field] --> B{Field border} B -->|Before| C[Normal border] B -->|After| D[Red border]Narrated recording, before then after (sound on):
text-email.mp4
Edge cases and unchanged behavior checked
Checked in the running editor (Vite dev server and
marimo editfrommainat a8d229e, then this branch, same notebook withmo.ui.text(kind="email"),mo.ui.text(kind="url")andmo.ui.text(kind="email", debounce=False)), and shown in the recording:not-an-emailin the email field andnot a urlin the url field, then Tab: no red border on either.jane@example.comand pressing Enter (no blur) clears the red border.https://marimo.io) is not flagged.debounce=Falseemail field still flagsnopeafter leaving it.Covered by tests only:
debounce=200.Tests
vitest run src/plugins/impl/__test__/text-labels.test.tsx: new test "marks an invalid email after blur" fordebounce=false,trueand200. Thedebounce=truecase fails onmainand passes on this branch; the other two pass on both.vitest run src/plugins/impl/: 55 files, 845 passed (4 expected fail).tsgo(frontend typecheck): clean.oxlintandoxfmt --checkon the changed files: clean.make check, the Python suite, e2e.AI assistance (Claude Code) was used for this change; the bug was reproduced and the fix checked in the running editor by the agent.
📋 Pre-Review Checklist
✅ Merge Checklist
🤖 Generated with Claude Code