-
Notifications
You must be signed in to change notification settings - Fork 86
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
fix(tab-nav): content clickable for screen readers #1692
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,33 +40,12 @@ export class TabNav { | |
/** (optional) Injected CSS styles */ | ||
@Prop() styles?: string; | ||
|
||
@Listen('click') | ||
handleClick(event: MouseEvent) { | ||
// To provent event bubbling. | ||
event.stopPropagation(); | ||
|
||
// workaround for slotted icons | ||
const targetHTMLElement = event.target as HTMLElement; | ||
const targetTag = targetHTMLElement.tagName.toLowerCase(); | ||
const svgTags = ['svg', 'g', 'path']; | ||
let nextTab: HTMLScaleTabHeaderElement; | ||
|
||
if (svgTags.includes(targetTag)) { | ||
const closestNextTab = targetHTMLElement.closest( | ||
`scale-tab-header[role="tab"]` | ||
) as HTMLScaleTabHeaderElement; | ||
if (closestNextTab) { | ||
nextTab = closestNextTab; | ||
this.selectTab(nextTab); | ||
} | ||
} else { | ||
if ( | ||
(event.target as HTMLScaleTabHeaderElement).getAttribute('role') === | ||
'tab' | ||
) { | ||
nextTab = event.target as HTMLScaleTabHeaderElement; | ||
this.selectTab(nextTab); | ||
} | ||
@Listen('scale-select') | ||
handleSelect(event) { | ||
const nextTab = event.target as HTMLScaleTabHeaderElement; | ||
// Act only if it's a direct child | ||
if (this.getAllEnabledTabs().includes(nextTab)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...or this takes care of collisions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this takes care of collisions with nested tabs… (an issue we had reported not long ago) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually with nested anything haha |
||
this.selectTab(nextTab); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we scope this event to avoid collisions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could, but I think it makes sense to also have this event be "public", no?