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

Not properly processing lists #2415

Closed
GregJohnStewart opened this issue Jul 23, 2020 · 4 comments
Closed

Not properly processing lists #2415

GregJohnStewart opened this issue Jul 23, 2020 · 4 comments

Comments

@GregJohnStewart
Copy link

I have the following list that forms some navigational elements:

<ul class="nav nav-tabs" id="mainTab" role="tablist">
	<li class="nav-item">
		<a class="nav-link active" id="loginSettingsTab" data-toggle="tab" href="#loginSettingsContent" role="tab" aria-controls="loginSettingsContent" aria-selected="true">
			<i class="fas fa-key fa-fw"></i> Login
		</a>
	</li>
	<li class="nav-item">
		<a class="nav-link" id="accountDetailsTab" data-toggle="tab" href="#accountDetailsContent" role="tab" aria-controls="accountDetailsContent" aria-selected="false">
			<i class="fas fa-info fa-fw"></i> Account Details
		</a>
	</li>
	<li class="nav-item">
		<a class="nav-link" id="notificationsTab" data-toggle="tab" href="#notificationsContent" role="tab" aria-controls="notificationsContent" aria-selected="false">
			<i class="far fa-bell fa-fw"></i> Notifications
		</a>
	</li>
</ul>

However, I get the following error messages:

Found 1 accessibility violations:
1) <li> elements must be contained in a <ul> or <ol>: https://dequeuniversity.com/rules/axe/3.1/listitem?application=axeAPI
  a) ["#mainTab > li:nth-child(1)"]
    Fix any of the following:
      List item does not have a <ul>, <ol> or role="list" parent element


  b) ["#mainTab > li:nth-child(2)"]
    Fix any of the following:
      List item does not have a <ul>, <ol> or role="list" parent element


  c) ["li:nth-child(3)"]
    Fix any of the following:
      List item does not have a <ul>, <ol> or role="list" parent element

I believe that my html is valid, and should not make this error.

@straker
Copy link
Contributor

straker commented Jul 24, 2020

I believe the issue is since the ul has a role of tablist, each <li> child is being reported as missing the parent ul without a role. You'll need to add role=presentation to each of the <li>s in order for the structure to be correct.

@GregJohnStewart
Copy link
Author

Unfortunately, that produces the following error:

2) ARIA role must be appropriate for the element: https://dequeuniversity.com/rules/axe/3.1/aria-allowed-role?application=axeAPI
  a) ["#loginSettingsTab"]
    Fix any of the following:
      role presentation  is not allowed for given element

@straker
Copy link
Contributor

straker commented Jul 24, 2020

That's strange, I don't get that error when I have the structure:

<ul class="nav nav-tabs" id="mainTab" role="tablist">
	<li class="nav-item" role="presentation">
		<a class="nav-link active" id="loginSettingsTab" data-toggle="tab" href="#loginSettingsContent" role="tab" aria-controls="loginSettingsContent" aria-selected="true">
			<i class="fas fa-key fa-fw"></i> Login
		</a>
	</li>
	<li class="nav-item" role="presentation">
		<a class="nav-link" id="accountDetailsTab" data-toggle="tab" href="#accountDetailsContent" role="tab" aria-controls="accountDetailsContent" aria-selected="false">
			<i class="fas fa-info fa-fw"></i> Account Details
		</a>
	</li>
	<li class="nav-item" role="presentation">
		<a class="nav-link" id="notificationsTab" data-toggle="tab" href="#notificationsContent" role="tab" aria-controls="notificationsContent" aria-selected="false">
			<i class="far fa-bell fa-fw"></i> Notifications
		</a>
	</li>
</ul>

@GregJohnStewart
Copy link
Author

Ahh I was being dumb, I just replaced the link's role, not giving the li one. Putting the role on the li fixed it, thanks for the points!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants