Closed qzminski closed 5 years ago
I've tested this and cannot reproduce in the latest Firefox.
I have this issue now as well. Firefox and Chrome select the first value even though there is an empty option. Safari works correctly.
That's a tough one. I guess Safari and Chrome differ in how to they internally process the DOM change and how/when element.value
can be accessed. I guess, in Safari element.value
longer stays ""
before it changes to the actual value, e.g. DE-BW
.
WDYT of 353f0c9?
Looks good. Just a quick guess: If we do not have a default option, we still want the first option to be selected (or the browser will select it anyway), right? So maybe we don't need that check at all? I guess the idea of if (element.value)
was to not change the current value if an option with the same value existed. But if we shuffle the options, we might as well reset the value?
If we remove the block if (!element.value)
, the first option will always be selected, even if one option should be selected per default (see lines 24f.).
So the current behavior should be: If default option available, it will be selected (lines 24ff), if not, the first one (may be the blank option) will be selected (lines 105ff).
What do you mean by shuffling the options?
Ah I see. So maybe the variable should rather be selectDefaultOption
?
I'll rename. How to minify the js?
Looks like theres nothing in place to minify, I guess I just used any online or CLI tool back in the days. Feel free to use any dirty way. For new extensions that is Contao 4 only, I would use Webpack, but that does not make sense here as we don't have an src
folder etc.
When the condition field is changed and the new options are generated, the conditional field in Firefox takes the value of the first non empty option and thus it is selected by default.
Any ideas how to fix that?
https://github.com/terminal42/contao-conditionalselectmenu/blob/master/assets/conditionalselect.js#L105