Skip to content

Commit

Permalink
refactor(typeahead): rename windowClass to popupClass
Browse files Browse the repository at this point in the history
Publicly we're saying typeahead popup, not window
  • Loading branch information
maxokorokov committed Mar 23, 2021
1 parent dd56af1 commit 9c5651d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/typeahead/typeahead-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ResultTemplateContext {
encapsulation: ViewEncapsulation.None,
host: {
'(mousedown)': '$event.preventDefault()',
'[class]': '"dropdown-menu show" + (windowClass ? " " + windowClass : "")',
'[class]': '"dropdown-menu show" + (popupClass ? " " + popupClass : "")',
'role': 'listbox',
'[id]': 'id'
},
Expand Down Expand Up @@ -80,8 +80,10 @@ export class NgbTypeaheadWindow implements OnInit {

/**
* A custom class to append to the typeahead window
*
* @since 9.1.0
*/
@Input() windowClass: string;
@Input() popupClass: string;

/**
* Event raised when user selects a particular result row
Expand Down
6 changes: 3 additions & 3 deletions src/typeahead/typeahead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ describe('ngb-typeahead', () => {

it('should apply additional class when specified', () => {
const fixture =
createTestComponent(`<input type="text" [(ngModel)]="model" [ngbTypeahead]="find" windowClass="test"/>`);
createTestComponent(`<input type="text" [(ngModel)]="model" [ngbTypeahead]="find" popupClass="test"/>`);
const compiled = fixture.nativeElement;

// the results of the code below are already tested above
Expand All @@ -454,8 +454,8 @@ describe('ngb-typeahead', () => {
});

it('should apply additional classes when specified', () => {
const fixture = createTestComponent(
`<input type="text" [(ngModel)]="model" [ngbTypeahead]="find" windowClass="test other"/>`);
const fixture =
createTestComponent(`<input type="text" [(ngModel)]="model" [ngbTypeahead]="find" popupClass="test other"/>`);
const compiled = fixture.nativeElement;

// the results of the code below are already tested above
Expand Down
4 changes: 2 additions & 2 deletions src/typeahead/typeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class NgbTypeahead implements ControlValueAccessor,
*
* @since 9.1.0
*/
@Input() windowClass: string;
@Input() popupClass: string;

/**
* An event emitted right before an item is selected from the result list.
Expand Down Expand Up @@ -315,7 +315,7 @@ export class NgbTypeahead implements ControlValueAccessor,
this._windowRef.instance.id = this.popupId;
this._windowRef.instance.selectEvent.subscribe((result: any) => this._selectResultClosePopup(result));
this._windowRef.instance.activeChangeEvent.subscribe((activeId: string) => this.activeDescendant = activeId);
this._windowRef.instance.windowClass = this.windowClass;
this._windowRef.instance.popupClass = this.popupClass;

if (this.container === 'body') {
this._document.querySelector(this.container).appendChild(this._windowRef.location.nativeElement);
Expand Down

0 comments on commit 9c5651d

Please sign in to comment.