Skip to content

Commit

Permalink
fix(core): type incorrect assumption of input always existing (#12240)
Browse files Browse the repository at this point in the history
* fix(core): type incorrect assumption of input always exsiting

* fix(core): remove redundant example from multi-input
  • Loading branch information
ZsDeak-SAP authored Sep 10, 2024
1 parent 5ae2a55 commit 1c723ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { MultiAnnouncerDirective } from './multi-announcer.directive';

@Component({
template: ` <input [options]="values" fdMultiAnnouncer />`
template: ` <input fdMultiAnnouncer />`
})
class TestComponent {
@ViewChild(MultiAnnouncerDirective)
multiAnnouncerDirective: MultiAnnouncerDirective;

values: string[] = ['Apple', 'Pineapple', 'Banana', 'Kiwi', 'Strawberry'];
}

describe('MultiAnnouncerDirective', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LiveAnnouncer } from '@angular/cdk/a11y';
import { ContentChildren, Directive, HostListener, inject, Input, QueryList } from '@angular/core';
import { KeyUtil } from '@fundamental-ngx/cdk/utils';
import { TokenComponent } from '@fundamental-ngx/core/token';
import { resolveTranslationSyncFn } from '@fundamental-ngx/i18n';
import { FdLanguageKeyIdentifier, resolveTranslationSyncFn } from '@fundamental-ngx/i18n';

@Directive({
selector: '[fdMultiAnnouncer]',
Expand Down Expand Up @@ -39,29 +39,22 @@ export class MultiAnnouncerDirective {
private _makeSearchTermChangeAnnouncements(event: KeyboardEvent): void {
if (KeyUtil.isKeyType(event, 'alphabetical') || KeyUtil.isKeyType(event, 'numeric')) {
this._liveAnnouncer.clear();
if (!this.multiAnnouncerOptions.length && !this._noResultsAnnounced) {
const count = this.multiAnnouncerOptions?.length;
if (!count && !this._noResultsAnnounced) {
this._buildAnnouncement(this._resolveTranslation('coreMultiInput.noResults'));
this._noResultsAnnounced = true;
this._resultsAnnounced = false;
} else if (this.multiAnnouncerOptions.length) {
if (this.multiAnnouncerOptions.length === 1) {
this._buildAnnouncement(
this._resolveTranslation('coreMultiInput.countListResultsSingular', { count: 1 })
);
} else {
this._buildAnnouncement(
this._resolveTranslation('coreMultiInput.countListResultsPlural', {
count: this.multiAnnouncerOptions.length
})
);
}
} else if (count) {
const trKey: FdLanguageKeyIdentifier =
count === 1 ? 'coreMultiInput.countListResultsSingular' : 'coreMultiInput.countListResultsPlural';
this._buildAnnouncement(this._resolveTranslation(trKey, { count }));
this._buildAnnouncement(this._resolveTranslation('coreMultiInput.navigateSelectionsWithArrows'));
if (!this._resultsAnnounced) {
this._noResultsAnnounced = false;
this._resultsAnnounced = true;
}
}
if (this._tokens && this._tokens.length) {
if (this._tokens?.length) {
this._buildAnnouncement(this._resolveTranslation('coreMultiInput.escapeNavigateTokens'));
}
this._makeAnnouncement(this._announcement);
Expand Down

0 comments on commit 1c723ce

Please sign in to comment.