Skip to content

Commit

Permalink
fix: add prop for removing tabindex
Browse files Browse the repository at this point in the history
  • Loading branch information
felixw committed Nov 21, 2023
1 parent 4229de7 commit 35e2252
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/components/src/components/tab-panel/tab-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class TabPanel {
/** (optional) size */
/** @deprecated - no more size difference */
@Prop() size: 'small' | 'large' = 'small';
/** (optional) adds tab-index="0" to the panel, set to false to exclude the tab-panel from the tab sequence, e.g. if the first element in the panel is a focusable button */
@Prop() tabbablePanel?: boolean = true;
/** (optional) Injected CSS styles */
@Prop() styles?: string;

Expand All @@ -43,12 +45,18 @@ export class TabPanel {
}
}

setTabIndex() {
if (this.tabbablePanel === true) {
return { tabindex: '0' };
}
}

render() {
return (
<Host
id={`scale-tab-panel-${this.generatedId}`}
role="tabpanel"
tabindex="0"
{...this.setTabIndex()}
>
{this.styles && <style>{this.styles}</style>}
<div part="tab-panel" class="tab-panel">
Expand Down

0 comments on commit 35e2252

Please sign in to comment.