Closed depeele closed 6 years ago
"selected" attribute on <x-menuitem>
is not a boolean attribute, it is a tristate attribute. AFAIK tristate attribute type is not defined by HTML, but it is used by many ARIA attributes.
The possible values are:
<x-menuitem selected="true">
- menu item is selected (draw the checkmark)<x-menuitem selected="false">
- menu item is not selected (draw the checkmark, but make it invisible)<x-menuitem>
- menu item is not selectable (don't draw the checkmark)I would have thought an unselectable menu item would be represented by an <x-menuitem>
with a disabled
property...
How does disabled
differ from selected=null
?
Disabled menu item is greyed out and it does not change appearance when hovered, as demonstrated on https://xel-toolkit.org/elements/x-menuitem
So, if I'm following the documentation, code, and comments correctly, <x-menuitem>
treats the selected
attribute as a tristate to allow the component to be used within an <x-select>
and, in that case, receive a default checkmark icon placeholder that is used to identify the selected value(s).
Is that correct?
Menu items inside <x-menubar>
or <x-button>
could be togglable (i.e. show a checkmark or a placeholder for a checkmark) as well.
I agree though that the selected
attribute with a tristate type is confusing and we should probably replace it with two separate boolean attributes. Lets discuss it in #59.
When using boolean attributes, the spec states:
For
x-select
, xel was using the literal stringtrue
when searching for the currently selected item. This misses the selected item when using attribute presence/absence to indicate the boolean value.This pull request should allow for both usages -- attribute presence/absence or an attribute with an explicit value that is not
false
.