Skip to content
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

Menu items that are neither <a> nor <span> do not show border #351

Closed
db6edr opened this issue Dec 23, 2021 · 3 comments
Closed

Menu items that are neither <a> nor <span> do not show border #351

db6edr opened this issue Dec 23, 2021 · 3 comments
Labels

Comments

@db6edr
Copy link

db6edr commented Dec 23, 2021

Steps to reproduce

Create some markup like

<div class="py-4 artboard artboard-demo bg-base-200">
  <ul class="menu py-4 shadow-lg bg-base-100 rounded-box">
    <li class="menu-title">
      <span>
            Menu Title
          </span>
    </li> 
    <li class="bordered disabled">
      Item is disabled
    </li> 
    <li class="bordered">
      It has border
    </li> 
    <li class="hover-bordered">
      It shows border on hover
    </li>
  </ul>
</div>

Yes, that's an adapted version of the bordered example at https://daisyui.com/components/menu

Expected behavior

Judging from where the classes are attached, I expect the <li> to show the border regardless of what children they have. Or at least for all clickable HTML elements.

Actual behavior

The <li> show the border if and only if their child is an <a> or <span>.

Why is this bad?

Accessibility is impaired: following WCAG and a11y-101.com, <a> should only be used when clicking the element triggers a navigation to another page. When clicking an element just changes some state on the page, use a <button>.

@saadeghi
Copy link
Owner

I don't think giving clickable style to the whole <li> is a good idea because there can be multiple elements inside an <li>
Currently li > a and li > span have clickable style so I guess adding li > button will fix the accessibility issue you mentioned. Right?

@db6edr
Copy link
Author

db6edr commented Dec 23, 2021

I don't think the left-hand border is clickable style, it's rather a kind of highlighting for menu items. And yes, the <li> can grow big - in this case, the highlight should grow as well. And if I'm not mistaken, it already does for li.bordered > a and li.bordered > span.
Back to you question: yes, having li.bordered > button render the border will fix both the a11y issue and my use case.

A more complete fix would be to have the actual li.bordered rendering the border, without adding restrictions on what children that node can have. This would give the developer working with daisyUI more freedom in how (s)he structures the markup.

@db6edr
Copy link
Author

db6edr commented Jan 17, 2022

@saadeghi Thanks!

@saadeghi saadeghi added the menu label Feb 21, 2022
inorganik pushed a commit to inorganik/daisyui that referenced this issue Feb 7, 2023
imgbot bot pushed a commit to Avensen/daisyui that referenced this issue Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants