-
Notifications
You must be signed in to change notification settings - Fork 135
fix(core): fix Quick View Accessibility issues #5493
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...iew/quick-view-group-item-content/quick-view-group-item-content-element.directive.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { Component, ElementRef, ViewChild } from '@angular/core'; | ||
import { QuickViewGroupItemContentElementDirective } from './quick-view-group-item-content-element.directive'; | ||
|
||
@Component({ | ||
template: ` <div #directiveElement fd-quick-view-group-item-content-element> Element </div> ` | ||
}) | ||
class TestComponent { | ||
@ViewChild('directiveElement') | ||
ref: ElementRef; | ||
} | ||
|
||
describe('QuickViewGroupItemContentElementDirective', () => { | ||
let component: TestComponent; | ||
let fixture: ComponentFixture<TestComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TestComponent, QuickViewGroupItemContentElementDirective] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should assign class', () => { | ||
expect(component.ref.nativeElement.classList).toContain('fd-quick-view__group-item__content-element'); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
...ick-view/quick-view-group-item-content/quick-view-group-item-content-element.directive.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Directive } from '@angular/core'; | ||
|
||
@Directive({ | ||
// tslint:disable-next-line:directive-selector | ||
selector: '[fd-quick-view-group-item-content-element]', | ||
host: { | ||
class: `${QuickViewGroupItemContentElementDirective.class} fd-input` | ||
} | ||
}) | ||
export class QuickViewGroupItemContentElementDirective { | ||
/** @hidden */ | ||
static class = 'fd-quick-view__group-item__content-element'; | ||
} |
31 changes: 26 additions & 5 deletions
31
...c/lib/quick-view/quick-view-group-item-content/quick-view-group-item-content.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef } from '@angular/core'; | ||
|
||
import { QuickViewGroupItemContentElementDirective } from './quick-view-group-item-content-element.directive'; | ||
import { getClosest } from '@fundamental-ngx/core/utils'; | ||
|
||
@Component({ | ||
selector: 'fd-quick-view-group-item-content', | ||
templateUrl: './quick-view-group-item-content.component.html', | ||
host: { | ||
'[class.fd-input]': 'true' | ||
}, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class QuickViewGroupItemContentComponent {} | ||
export class QuickViewGroupItemContentComponent implements AfterViewInit { | ||
/** @hidden */ | ||
constructor(private readonly _elRef: ElementRef) {} | ||
|
||
/** @hidden */ | ||
ngAfterViewInit(): void { | ||
this._bindElementAttributes(); | ||
} | ||
|
||
/** @hidden | ||
* Needed for binding the id of the element and id of the proper label to aria-labelledby. */ | ||
private _bindElementAttributes(): void { | ||
const parentId = getClosest('.fd-form-item', this._elRef.nativeElement)?.id; | ||
const id = `${parentId}-content`; | ||
|
||
const element = this._elRef.nativeElement.querySelector(`.${QuickViewGroupItemContentElementDirective.class}`); | ||
if (element && parentId) { | ||
element.setAttribute('id', id); | ||
element.setAttribute('aria-labelledby', `${parentId}-label ${id}`); | ||
} | ||
} | ||
} |
23 changes: 21 additions & 2 deletions
23
...e/src/lib/quick-view/quick-view-group-item-label/quick-view-group-item-label.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef } from '@angular/core'; | ||
import { getClosest } from '@fundamental-ngx/core/utils'; | ||
|
||
@Component({ | ||
selector: 'fd-quick-view-group-item-label', | ||
templateUrl: './quick-view-group-item-label.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class QuickViewGroupItemLabelComponent {} | ||
export class QuickViewGroupItemLabelComponent implements AfterViewInit { | ||
/** @hidden */ | ||
constructor(private readonly _elRef: ElementRef) {} | ||
|
||
/** @hidden */ | ||
ngAfterViewInit(): void { | ||
this._bindElementAttributes(); | ||
} | ||
|
||
/** @hidden | ||
* Needed for binding the id to the label element (and this id needed for aria-labelledby of proper element). */ | ||
private _bindElementAttributes(): void { | ||
const parentId = getClosest('.fd-form-item', this._elRef.nativeElement)?.id; | ||
|
||
if (this._elRef.nativeElement.firstChild && parentId) { | ||
this._elRef.nativeElement.firstChild.setAttribute('id', `${parentId}-label`); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
libs/core/src/lib/quick-view/quick-view-group-item/quick-view-group-item.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div fd-form-item> | ||
<div fd-form-item [id]="id"> | ||
<ng-content></ng-content> | ||
</div> |
10 changes: 8 additions & 2 deletions
10
libs/core/src/lib/quick-view/quick-view-group-item/quick-view-group-item.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
|
||
let quickViewGroupItemUniqueId = 0; | ||
|
||
@Component({ | ||
selector: 'fd-quick-view-group-item', | ||
templateUrl: './quick-view-group-item.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class QuickViewGroupItemComponent {} | ||
export class QuickViewGroupItemComponent { | ||
/** Id of the quick view element. */ | ||
@Input() | ||
id: string = 'fd-quick-view-group-item-' + quickViewGroupItemUniqueId++; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.