Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Blur message to Input widget #5414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edward-jazzhands
Copy link
Contributor

@edward-jazzhands edward-jazzhands commented Dec 20, 2024

I realized working with the Input widget that its options for validate_on are "submitted", "changed", and "blur". However, there's only messages for Submitted and Changed. This makes it trickier to synchronize a function with the blur validator than it is with the other two validators, which I believe in this situation does not make sense.

Now I had figured a Blur event most likely does not exist for a reason (i.e. perhaps if one widget has it then why wouldn't all of them). But in this situation I can't help but feel like its existence is warranted in order to make the validate_on=['blur'] parameter be able to be used in a manner that's identical to "submitted" and "changed" without needing to subclass the Input widget.

The problem:

yield Input(value="foo", validate_on=['changed'], ...)

@on(Input.Changed)
def my_input_changed(self, event: Input.Changed):
    # This works
yield Input(value="foo", validate_on=['submitted'], ...)

@on(Input.Submitted)
def my_input_changed(self, event: Input.Submitted):
    # This works
yield Input(value="foo", validate_on=['blur'], ...)

@on(Input.Blur)
def my_input_blur(self, event: Input.Blur):
    # This does not work

a message when triggered to match the Submitted and Changed messages.
@edward-jazzhands edward-jazzhands changed the title Added Blur message to Input widget Add Blur message to Input widget Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant