-
Notifications
You must be signed in to change notification settings - Fork 65
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
Typeahead widget does not trigger onValue event when user clears the field (no selection) #1655
Comments
@arndbeissner thanks for raising this issue. It has started a discussion within our team regarding the behaviour of the typeahead and that of the select widget it is based upon and how a standard html select behaves with regard to deselection. Looking at the default behaviour of a native html select, it will select the first value (if no selected value is specified) and does not allow you to deselect. The standard way to get around this is to add an empty value The changes we put forward to achieve this are:
|
@tomdye thanks for looking quite deep into this. I think it's worth it, a good Typeahead widget is a core component of so many applications. What you outline seems to be a very flexible solution, and it also gives a way to make that "empty" selection from within the list, not just from within the textbox. I just have two amendments (which may already be on your list):
That being said, for 7.x, I will have to make a private fork with a simple behavior patch that makes onValue fire on empty, because honestly, I just can't ship as it is. Even if it's just a small admin application. |
I agree with both your amendments @arndbeissner , I thought they might have been implied by the changes I suggested but I'm thankful that you clarified. |
This issue is related to #583 also |
Bug
If set to controlled but not required the user can select items from the list which triggers the onValue event. This is expected and needed. However, if the user then emptied the Typeahead field so that there is no selection, the onValue event is NOT triggered. This is a critical bug as it does not allow for status changes on dependent widgets.
Package Version: @dojo/widgets 7.0.3
Code
The issue can be seen with Validation.tsx example from the Dojo widgets documentation. Just remove the required attribute from the widget, add alert("value=" + value ? value.label :" -"); to the existing onValue event.
Expected behavior:
The onValue event is triggered will value undefined (to set to empty the Typeahead wants undefined instead of null, so the event should use undefined as well).
Actual behavior:
The onValue event is not trigger when the user changes the Typeahead to be empty
The text was updated successfully, but these errors were encountered: