-
Notifications
You must be signed in to change notification settings - Fork 26
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
Check whether a focus state transition occurs #87
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracking "previous" state without dealing with didUpdateWidget()
tends to result in things getting out of sync when the widget is rebuilt. what if we relied on FocusNode.canRequestFocus
instead to avoid our own book keeping? it should be false if the widget is disabled and thus, not focusable, right?
if (_focusNode.canRequestFocus) widget.onSubmitted?.call(value);
I will check sync about |
Alternatively, we could propagate the "enabled" value from SpinBox and CupertinoSpinBox to BaseSpinBox or SpinBoxMixin so that it knows the value. |
"enabled" value from SpinBox and CupertinoSpinBox also can't avoid submit action when enable a disabled Spinbox, because "enabled" is always true in this situation. |
How about something like:
So onSubmitted is called only when the value changes, like in setValue. |
Actually, your proposition can cover most case. But a submit aciton is usually tiggered when an input widget lose focus or |
Hi @jpnurmi , I don't think there will be a synchronization problem without dealing with |
Checking for valid state transitions is necessary because
_handleFocusChanged
is called whenSpinbox
are enabled or disabled.I did not make this pull request when #80 occur because I am not sure what cause the problem.
Now I found that is relative to FocusNode behavior when propery
canRequestFocus
is changed inTextField
. I believe this pull request can close #80.