[Fix] 0047057 UI: Select field must not have more than one selected option#11009
[Fix] 0047057 UI: Select field must not have more than one selected option#11009thibsy merged 2 commits intoILIAS-eLearning:release_11from
Conversation
Annett7811
left a comment
There was a problem hiding this comment.
Hello!
From an accessibility perspective, this looks good. Thank you very much for your work.
Best regards,
Annett
oliversamoila
left a comment
There was a problem hiding this comment.
Hello together,
Thank you very much for your contribution, @fhelfer. Thanks you for your review, @Annett7811. I agree and don't see these issues anymore.
I'm forwarding this to @thibsy for code review. He may contact you with change requests or incorporate the changes directly (That includes cherry picking too.)
Kind regards,
@oliversamoila (as UI coordinator)
There was a problem hiding this comment.
Hi @fhelfer,
Thx a lot for your contribution to the UI framework!
Please implement the following changes:
- Ternary: please replace this ternary operation with a dedicated
ifstatement/block. We generally try to avoid ternary, because it decreases readability. While reading your code, I just had to double check that you do not set the selected-attribute all the time. -
$value_is_empty: please a) reuse the new variable and negate it, and b) remove the ternary operation here as well.
Sorry for the nitpicks.
Kind regards,
@thibsy (as UI coordinator)
* Fixes https://mantis.ilias.de/view.php?id=47057 * Update empty value check
* Fixes https://mantis.ilias.de/view.php?id=47057 * Update empty value check
When the select value was 0 (e.g. DataTable action dropdown), both the
placeholder option and the option with value "0" got selected="selected"
because PHP treats 0 as falsy. Use explicit empty check (value === null
|| value === '') for placeholder selection and clear SELECTED for
non-matching options so only one option is ever selected.
Problem
Lösung
$value_is_empty = ($value === null || $value === '')statt!$value.Error: The “select” element cannot have more than one selected “option” descendant unless the “multiple” attribute is specified.
https://mantis.ilias.de/view.php?id=47057