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

Improve tab navigations accessibility with Home and End keys #38471

Closed
2 tasks done
Rezyan opened this issue Apr 16, 2023 · 4 comments · Fixed by #38498
Closed
2 tasks done

Improve tab navigations accessibility with Home and End keys #38471

Rezyan opened this issue Apr 16, 2023 · 4 comments · Fixed by #38498

Comments

@Rezyan
Copy link

Rezyan commented Apr 16, 2023

Prerequisites

Proposal

I suggest to improve tab navigations (e.g. .nav-tabs) accessibility with the keyboard:

  • Home: moves focus to the FIRST tab and activates it.
  • End: moves focus to the LAST tab and activates it.

The idea is taken from the W3C example.

Motivation and context

This could be useful for users using keyboards, and this enhancement would be the continuation of #33079 (keyboard accessibility with arrow keys).

I've already implemented it in one of my website. This is much the same as the implementation for arrow keys. My jQuery code looks like below:

$(document).on('keydown', '.nav-link[data-bs-toggle="tab"]', (event) =>
{
	if (['Home', 'End'].includes(event.key))
	{
		event.preventDefault();
		const $tabs = $(event.currentTarget).parents('.nav[role="tablist"]').find('.nav-link[data-bs-toggle="tab"]').not('.disabled');
		const $tabToShow = (event.key === 'Home') ? $tabs.first() : $tabs.last();
		$tabToShow.get(0).focus({
			preventScroll: true
		});

		$tabToShow.tab('show');
	}
});
@yashviradia
Copy link

Hi,
I would like to work on this issue.
Could you pl assign it to me?

@Rezyan
Copy link
Author

Rezyan commented Apr 23, 2023

Hi, I would like to work on this issue. Could you pl assign it to me?

Hi, I think @julien-deramond could assign this issue to you. Thanks for your help.

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

Successfully merging a pull request may close this issue.

4 participants
@julien-deramond @Rezyan @yashviradia and others