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

fix(core): segmented button accessibility improvements #11054

Closed
wants to merge 2 commits into from
Closed
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
55 changes: 28 additions & 27 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,25 @@ concurrency:
cancel-in-progress: true

jobs:
agents:
name: Ubuntu latest
uses: nrwl/ci/.github/workflows/[email protected]
secrets:
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
with:
number-of-agents: 8
node-version: 16.x
yarn-version: 1.22.19
install-commands: |
yarn install --frozen-lockfile
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &

initialize_cloud:
nx_agents:
name: Nx Cloud Agent ${{ matrix.agent }}
runs-on: ubuntu-latest
name: Initialize Nx Cloud
strategy:
matrix:
agent: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/nodejs
- name: Initialize the Nx Cloud distributed CI run
run: npx nx-cloud start-ci-run
- name: set up xvfb
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &
- name: Start Nx Cloud Agent
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{matrix.agent}}

build_test:
needs: initialize_cloud
runs-on: ubuntu-latest
name: Run affected Build, Lint and test commands
defaults:
Expand All @@ -52,13 +45,24 @@ jobs:
- uses: actions/checkout@v3
name: Checkout
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- uses: nrwl/nx-set-shas@v2
name: Derive appropriate SHAs for base and head for nx-affected commands
with:
main-branch-name: main

- uses: ./.github/actions/nodejs

- name: Initialize the Nx Cloud distributed CI run
run: npx nx-cloud start-ci-run

- name: Format Check
run: npx nx format:check --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false

- uses: wagoid/commitlint-github-action@v3
name: Commit lint

Expand All @@ -68,15 +72,12 @@ jobs:
parallel-commands: |
npx nx affected --target=build --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=docs --parallel=3
npx nx affected --target=test --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=nx-plugin --parallel=3
npx nx affected --target=lint --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=core,platform,cx --parallel=3
npx nx run nx-plugin:test --skip-nx-cache
- name: Format Check
run: npx nx format:check --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
npx nx affected --target=lint --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=core,platform,cx,btp --parallel=3

- name: Text workspace tags
run: npx nx run nx-plugin:test --skip-nx-cache

e2e_test:
needs: initialize_cloud
runs-on: ubuntu-latest
name: Run affected e2e commands
defaults:
Expand Down
5 changes: 3 additions & 2 deletions libs/core/src/lib/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@angular/core';
import { BaseButton } from './base-button';
import { Subscription } from 'rxjs';
import { applyCssClass, CssClassBuilder } from '@fundamental-ngx/cdk/utils';
import { applyCssClass, CssClassBuilder, FocusableItemDirective } from '@fundamental-ngx/cdk/utils';
import { ContentDensityObserver, contentDensityObserverProviders } from '@fundamental-ngx/core/content-density';

import { FD_BUTTON_COMPONENT } from './tokens';
Expand Down Expand Up @@ -47,7 +47,8 @@ import { FD_BUTTON_COMPONENT } from './tokens';
provide: FD_BUTTON_COMPONENT,
useExisting: ButtonComponent
}
]
],
hostDirectives: [FocusableItemDirective]
})
export class ButtonComponent extends BaseButton implements OnChanges, CssClassBuilder, OnInit, OnDestroy {
/** The property allows user to pass additional css classes. */
Expand Down
23 changes: 17 additions & 6 deletions libs/core/src/lib/segmented-button/segmented-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import {
ContentChildren,
ElementRef,
forwardRef,
Host,
HostBinding,
HostListener,
Input,
OnDestroy,
Optional,
QueryList,
ViewEncapsulation
} from '@angular/core';
import { ButtonComponent, FD_BUTTON_COMPONENT } from '@fundamental-ngx/core/button';
import { filter, observeOn, startWith, takeUntil, tap } from 'rxjs/operators';
import { Subject, merge, fromEvent, asyncScheduler } from 'rxjs';
import { DestroyedService, KeyUtil } from '@fundamental-ngx/cdk/utils';
import { DestroyedService, FocusableListDirective, KeyUtil } from '@fundamental-ngx/cdk/utils';
import { ENTER, SPACE } from '@angular/cdk/keycodes';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

Expand All @@ -40,7 +42,7 @@ export type SegmentedButtonValue = string | (string | null)[] | null;
templateUrl: './segmented-button.component.html',
styleUrls: ['./segmented-button.component.scss'],
host: {
role: 'group'
role: 'listbox'
},
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -51,7 +53,8 @@ export type SegmentedButtonValue = string | (string | null)[] | null;
multi: true
},
DestroyedService
]
],
hostDirectives: [FocusableListDirective]
})
export class SegmentedButtonComponent implements AfterViewInit, ControlValueAccessor, OnDestroy {
/** Whether segmented button is on toggle mode, which allows to toggle more than 1 button */
Expand Down Expand Up @@ -89,8 +92,13 @@ export class SegmentedButtonComponent implements AfterViewInit, ControlValueAcce
constructor(
private readonly _changeDetRef: ChangeDetectorRef,
private readonly _elementRef: ElementRef,
private readonly _onDestroy$: DestroyedService
) {}
private readonly _onDestroy$: DestroyedService,
@Optional() @Host() private focusableList: FocusableListDirective
) {
if (this.focusableList) {
this.focusableList.navigationDirection = 'horizontal';
}
}

/** @hidden */
ngAfterViewInit(): void {
Expand Down Expand Up @@ -150,7 +158,10 @@ export class SegmentedButtonComponent implements AfterViewInit, ControlValueAcce
this._onRefresh$.next();
this._toggleDisableButtons(this._isDisabled);
this._pickButtonsByValues(this._currentValue);
this._buttons.forEach((button) => this._listenToTriggerEvents(button));
this._buttons.forEach((button) => {
button.elementRef.nativeElement.role = 'option';
this._listenToTriggerEvents(button);
});
});
}

Expand Down
Loading