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
1 change: 1 addition & 0 deletions .ng-dev/commit-message.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const commitMessage: CommitMessageConfig = {
'cdk-experimental/scrolling',
'cdk-experimental/selection',
'cdk-experimental/table-scroll-container',
'cdk-experimental/tabs',
'cdk-experimental/ui-patterns',
'cdk/a11y',
'cdk/accordion',
Expand Down
30 changes: 9 additions & 21 deletions src/cdk-experimental/ui-patterns/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class TabListPattern {
/** The id of the current active tab. */
activedescendant = computed(() => this.focusManager.getActiveDescendant());

/** Whether selection should follow focus. */
followFocus = computed(() => this.inputs.selectionMode() === 'follow');

/** The key used to navigate to the previous tab in the tablist. */
Expand All @@ -154,33 +155,20 @@ export class TabListPattern {

/** The keydown event manager for the tablist. */
keydown = computed(() => {
const manager = new KeyboardEventManager();

if (this.followFocus()) {
manager
.on(this.prevKey, () => this.prev({selectOne: true}))
.on(this.nextKey, () => this.next({selectOne: true}))
.on('Home', () => this.first({selectOne: true}))
.on('End', () => this.last({selectOne: true}));
} else {
manager
.on(this.prevKey, () => this.prev())
.on(this.nextKey, () => this.next())
.on('Home', () => this.first())
.on('End', () => this.last())
.on(' ', () => this._updateSelection({selectOne: true}))
.on('Enter', () => this._updateSelection({selectOne: true}));
}
const manager = new KeyboardEventManager()
.on(this.prevKey, () => this.prev({selectOne: this.followFocus()}))
.on(this.nextKey, () => this.next({selectOne: this.followFocus()}))
.on('Home', () => this.first({selectOne: this.followFocus()}))
.on('End', () => this.last({selectOne: this.followFocus()}))
.on(' ', () => this.selection.selectOne())
.on('Enter', () => this.selection.selectOne());

return manager;
});

/** The pointerdown event manager for the tablist. */
pointerdown = computed(() => {
const manager = new PointerEventManager();
manager.on(e => this.goto(e, {selectOne: true}));

return manager;
return new PointerEventManager().on(e => this.goto(e, {selectOne: true}));
});

constructor(readonly inputs: TabListInputs) {
Expand Down
Loading