Skip to content

ValidatedEntryBox: validate as the value changes - #273

Merged
Felix-Mallinder merged 2 commits into
developfrom
Python_Toolkit-#271-LiveEntryValidation
Nov 24, 2026
Merged

Felix-Mallinder merged 2 commits into
developfrom
Python_Toolkit-#271-LiveEntryValidation

Conversation

@Felix-Mallinder

@Felix-Mallinder Felix-Mallinder commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Issues addressed by this PR

Closes #271

ValidatedEntryBox only validated on focus out and Return, so a success tick from an earlier value stayed while an invalid value was typed, and the error only showed on submit.

  • The entry now validates on every change: an invalid value loses the tick and shows its error straight away.
  • An empty optional entry shows neither mark.
  • New validate_on_change argument (default True); False keeps the old behaviour.

Test files

Python_Engine/Python/tests/test_bhom_tkinter_ui.py::test_widget_validation (new live and opt-out cases). All 5 tests in the file pass.

Changelog

  • ValidatedEntryBox validates as the value is typed; added validate_on_change to opt out.

Additional comments

Note that on_validate callbacks now fire on each keystroke rather than only on focus out.

🤖 Generated with Claude Code

Validation only ran on focus out and Return, so a success tick stayed while an
invalid value was typed. The entry now validates on every change (an empty
optional entry shows no mark). validate_on_change=False keeps the old behaviour.

Closes #271

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Felix-Mallinder Felix-Mallinder added the type:bug Error or unexpected behaviour label Nov 20, 2026
@Felix-Mallinder Felix-Mallinder self-assigned this Nov 20, 2026

@SimosManiatis SimosManiatis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the tests locally (Py 3.13 and 3.10): all 5 in test_bhom_tkinter_ui.py pass.

1.Clearing an optional field doesn't call on_validate(True). Type abc, then delete it: on_validate gets False and never True, so a caller that enables Submit from it stays stuck. Could the empty-optional branch in _on_value_change also call _call_validate_callback(True)?

2.The empty optional tick comes back on focus out. Live typing clears both marks, but validate() (focus out / Return) still shows ✓ for an empty optional entry. Worth making the two consistent, probably in validate().

3.Errors appear mid-typing (-, or 5 on the way to 50 with min 10). Fine if intended. Alternatively, show the tick live but only show errors after a short pause or on focus out.

Live validation now only clears a stale success mark and reports validity
to on_validate; errors show on focus out / Return. Clearing an optional
entry reports valid, and validate() no longer ticks an empty optional entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@SimosManiatis SimosManiatis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So all good nothing major but take a look at these below:

1.Clearing an optional field now goes through the empty branch in validate(), which calls _call_validate_callback(True). After an invalid value, set("") reports valid, so a Submit button driven by on_validate can turn back on.

2.That branch calls clear_error() instead of _show_success(). Focus out and Return leave an empty optional entry with neither mark, same as live typing.

3.An invalid value drops the tick straight away and on_validate gets False. The error label stays blank until focus out or Return, which is the option from the last review.

@Felix-Mallinder

Copy link
Copy Markdown
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci

bhombot-ci Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Felix-Mallinder to confirm, the following actions are now queued:

  • check ready-to-merge

There are 7 requests in the queue ahead of you.

@Felix-Mallinder
Felix-Mallinder merged commit 5d5ee53 into develop Nov 24, 2026
19 checks passed
@Felix-Mallinder
Felix-Mallinder deleted the Python_Toolkit-#271-LiveEntryValidation branch November 24, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Error or unexpected behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ValidatedEntryBox keeps the success tick while an invalid value is typed

2 participants