Read-only menu items
See original GitHub issueIt would be great if we could add a read-only menu item, for example to show a status, version number, or other static info. A read-only menu item should not be selectable and it should not close the menu when the user clicks or presses enter on it.
The existing readOnly
prop might be used for this functionality. The disabled
prop could work too, but it doesn’t cover the purpose as nicely. Currently, these props simply get passed on to the rendered span
, where they don’t have any effect on the behavior of the menu item.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
HTML attribute: readonly - HTML: HyperText Markup Language
The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.
Read more >HTML form readonly SELECT tag/input - javascript
This finds all select elements with a readonly attribute, then finds all options inside those selects that are not selected, then it hides...
Read more >MenuItem ReadOnly Property `type` · Issue #4097
When you try to change a menu items type, it won't let you... how do you? Uncaught Exception: TypeError: Cannot assign to read...
Read more >Context Menu in Read Only Texbox - MSDN - Microsoft
Since the only thing you can do with a ReadOnly textbox is copy , the user has to select some text and then...
Read more >HTML DOM Input Text readOnly Property
The readOnly property sets or returns whether a text field is read-only, or not. A read-only field cannot be modified. However, a user...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree there should be a disabled option natively supported by the library. However can’t promise a specific date when we will be able to implement that. Currently there are lot a of things going on to improve in the library related to the legacy code.
I have added this feature to the product roadmap https://github.com/davidtheclark/react-aria-menubutton/projects/1
Hopefully will be implemented in sometime.
Thanks for your replies and sample, @shirshendubhowmick. I understand I could check if a selected item should be handled, but my idea about supporting read-only items would be that the library checks this before calling the selection handler in the first place. It would also eliminate these items from the focus cycle.
In fact, as #67 shows, including an element other than a
MenuItem
results in this exact behavior.