Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-mangos-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/ds-core': minor
---

**tabs**: new property handleAsTabList to control navigation via keyboard to use arrow or either tabulator
8 changes: 8 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,10 @@ export namespace Components {
* Find the options properties by its value
*/
"getOptionByValue": (value: string) => Promise<BalTabOption>;
/**
* If `true` then isTabList becomes true even if there is a link in the list.
*/
"handleAsTabList": boolean;
/**
* Defines the layout of the tabs.
*/
Expand Down Expand Up @@ -8442,6 +8446,10 @@ declare namespace LocalJSX {
* If `true` the tabs is a block element and uses 100% of the width
*/
"fullwidth"?: boolean;
/**
* If `true` then isTabList becomes true even if there is a link in the list.
*/
"handleAsTabList"?: boolean;
/**
* Defines the layout of the tabs.
*/
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/components/bal-tabs/bal-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ export class Tabs
*/
@Prop() dimInactiveElements = false

/**
* If `true` then isTabList becomes true even if there is a link in the list.
*/
@Prop() handleAsTabList = false

@Watch('value')
protected async valueChanged(newValue?: string, oldValue?: string) {
if (newValue !== oldValue) {
Expand Down Expand Up @@ -426,8 +431,12 @@ export class Tabs
return Array.from(this.el.querySelectorAll('.bal-tabs__nav__item'))
}

/**
* Tells if the component acts as a tab or link list.
* If only one link is in the list and handleAsTabList has been set to false it will be a link list
*/
private get isTabList(): boolean {
return this.store.filter(tab => !!tab.href).length === 0
return this.store.filter(tab => !!tab.href).length === 0 || this.handleAsTabList
}

private get items(): HTMLBalTabItemElement[] {
Expand Down Expand Up @@ -772,7 +781,8 @@ export class Tabs
}

async focus(tab: BalTabOption) {
const hasKeyboardFocus = this.el.querySelector<HTMLButtonElement>(`button.bal-focused`) !== null
const hasKeyboardFocus =
this.el.querySelector<HTMLButtonElement | HTMLAnchorElement>(`button.bal-focused, a.bal-focused`) !== null

if (this.swiper.isActive()) {
const options = await this.getOptions()
Expand Down