Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I investigated the issue mentioned in #2545.
Strictly speaking, include_blank is not completely broken—it does exist as a feature and works correctly, but it is not visually reflected, making it unintuitive.
In a typical select dropdown, you would select the empty option at the top to cancel a selected option. However, in Selectize, the expected way to remove a selection is by pressing "Backspace."
While this behavior is correct once you know about it, it is not very intuitive.
To make it more intuitive, I added
allowEmptyOption
to Selectize.I tested it in several cases, and it seems safe to keep this set to
true
at all times. For selects withoutinclude_blank
(e.g.,customer.kind
), the blank option did not appear, so it should be fine.However, the blank option's height was too narrow, making it difficult to click. To address this, I adjusted the CSS.
(Since there was no dedicated CSS for Selectize, I added the styles to the form. Please let me know if there is a more appropriate place for them.)
Next, I made some changes to allow verification in the demo app.
Since
product.release_year
was already defined in the Model to allow blank values, I addedinclude_blank
in the Dashboard as well.For
customer.territory
, which is aBelongsTo
association, I made some modifications to verify that it behaves the same as a regular select.Since we have already confirmed that
true
works for other selects, I specified a string forprompt
to check how it behaves when passing a string value.I consider this fix to be temporary.
In the latest version of Selectize (
@selectize/selectize
), new options related to empty selections have been introduced, and CSS for blank options also seems to be prepared.Therefore, rather than making extensive modifications, I believe it is sufficient to adjust the appearance with minimal changes.