Skip to content

Conversation

goosys
Copy link
Contributor

@goosys goosys commented Feb 25, 2025

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 without include_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 added include_blank in the Dashboard as well.

image

For customer.territory, which is a BelongsTo 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 for prompt to check how it behaves when passing a string value.

image


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.

@nickcharlton
Copy link
Member

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.

Would we be better off in upgrading Selectize to use these new options?

@goosys
Copy link
Contributor Author

goosys commented Mar 20, 2025

I think it's better to update to the latest version, but I saw a comment in another issue suggesting there might be a reason not to update. I assumed there might be some specific circumstances.

If there are no issues, I’d like to go ahead with the update.

@nickcharlton
Copy link
Member

Let's update first and we can see what breaks. Thanks!

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.

2 participants