-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Dropdown] Add Nullable Option for Single Selection #2072
Comments
Hi, please check the readme. Please include a jsfiddle demonstrating your bug and a set of reproducible steps. |
Ok, here's the fiddle: https://jsfiddle.net/christiank/vf7r42ku/ As you see, the first select is ok: No empty value provided in select, no empty value found in dropdown. |
Empty values are used to pass in placeholder text (i.e. "Select Text.."), a few people have complained about this being idiosyncratic. I need to evaluate whether it makes sense to change this functionality in |
Well, I think we should consider keeping as most backward compatibility as possible, so in my opinion, I would prefer one of the following options:
Just created a fiddle to show how this could work with some magic aka. automatization: https://jsfiddle.net/christiank/khy2z55x/ Some things i fall into was that most options I tried break responsibility. However, I'm not the best JS/HTML-Guru, more type of a PHP-Guru. |
I think adding a placeholder setting, that when passed |
Added in |
http://jsfiddle.net/8ha5Ltve/ Fiddle with |
However, I think this does not solve the problem: how do you undo the selection in a NOT required select? This is the business case I stept into and it seems that your fiddle does not solve this problem. Even if the select is providind an empty option. |
I totally agree with @zelenin , using an option without a value attribute is quite a dirty solution. Including regarding to form generators in Symfony2 and ZF2. For me, it is not a solution to modify form generator templates just to make it possible to undo selection. Including backward compatibility, I propose the following solution:
|
I'll circle around this week. |
I also agree with @chrisandchris and @zelenin. It's really hard to work with a select box which has less features than a native one. It's being a big issue both on undoing the selection and also on the edit pages to update a record having a value already selected. |
There's docs on both clearing dropdowns and restoring to page load defaults. Can you elaborate on what's missing @canyildiz? |
@jlukic thank you for preparing those detailed docs. I really appreciate this. But I don't think putting a "Clear" button near the select box is same as selecting the first empty option of select. Second is the common behavior all web users are used to. |
@jlukic clear button is a workaround for hack that you are using for placeholder. Dropdown must be maximally repeating native select behavior. Only then it may be more featureous without risk for native features. |
Im in the same boat as @chrisandchris
Where the user can select A and then change their mind and re-select None. Having a reset button is not a solution. A nullable option that can be passed to .dropdown() would be a great backwards compatible option. Forcing value="" empty string options to disappear after a user selects is not inline with how the native select works. |
I like the idea of |
Any timeframe on this? Do you want me to have a go at implementing it and doing a PR? |
Wow - more than 2 years have passed and there is still no official way how to do this??? |
Slightly improved version of @ashkonBG script https://jsfiddle.net/hghkwkgv/1/ Also consider to use if(value!="") instead of if(value) to allow 0 as legit select option. Only bad thing about this solution is that onChange event is not fired when you initialize that field, so you can't clear/reset default selected value which is set on page loading. Edit: |
@DarkSide666 I believe that we can fork and start a new branch since officer is dead~_~ |
@greatbody Well, yes it looks that @jlukic have no activity for more than 1 month and previously he's not that active too this year. Sad to see that such good repo like Semantic-UI is going down this way. 142 open pull requests, 1070 open issues :( |
Sad to see yes, everyone thinks open source is cool and free, maybe use donation button more often. |
I already contribute in multiple open-source projects. That's my 2-cents to open-source community :) |
Contribution is important to open-source projects and all, but what I think others are trying to say is that new features are being added to the project; but this very major, yet so simple, issue still exists that shouldn't have been there since the early version. |
@ashkonBG I completely agree with you |
I've been a lead on an open-source project for over 10 years. You are not getting any money off it. Donations or ads won't help. The goal is to have multiple secondary officers who would be able to take over, approve PRs and move project ahead should something happen with the lead. In a current situation, we've invested a tons of work into https://github.com/atk4/ui to use Semantic UI over any other CSS framework. I still think it's a right choice and if we have to support this project somehow, we would be happy to help. But being open-source guys ourselves, we can't put any funds in. |
I really like the syntax of semantic-ui because it's highly readable and much more easier to write as other frameworks, like bootstrap. But, even with that in mind, it is quite impossible imho to succeed for semantic-ui when the founder does not give any permission/possibility for other people to manage work for him. There is a huge bunch of pull requests open and quite a lot of issues. Forking isn't an option, because a fork will just sink in the dump of forks... So as long as @jlukic does not respond, it's just as it is. I myself would be able to spend some hours a week to manage issues and pull requests, and I would like to do that for such a good piece of software. |
check in to gitter.im / semantic-ui there are some other people who are willing to help. |
@romaninsh But in the end it depends on the founder (@jlukic) to respond, so that he can grant someone access to maintain the repository/project/website. |
I found adding a new row to database {id:-1, value: null} is the easiest way to deal with this issue. |
Here is a patch that you can use to add a new option to $fn.dropdown(); https://github.com/BisManOnline/Semantic-UI-dropdown-selectPlaceholder This patch will allow you to set: allowPlaceholderSelect : true; |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
bump |
Yet another Bump |
Here's a workaround: If you add something like Just make sure your form processing function realizes that a zero value is a non-choice/null. |
Got Yet another Bump |
You might want to take a look at this: https://fomantic-ui.com/modules/dropdown.html#clearable-selection |
I've added a Pass in |
If converting any select to a dropdown, for example
The select is not required, so an empty selection is valid. We already have a value selected (given by something else). But it is not possible to select an empty value from the generated dropdown.
The text was updated successfully, but these errors were encountered: