Skip to content

Commit

Permalink
fix(14716): Allow disabled (but programmatically selected) option to …
Browse files Browse the repository at this point in the history
…be taken into account as the selected option label
  • Loading branch information
Cr3aHal0 committed Feb 7, 2024
1 parent ec19737 commit a1118c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
const visibleOptions = this.visibleOptions();

if (visibleOptions && ObjectUtils.isNotEmpty(visibleOptions)) {
const selectedOptionIndex = this.findSelectedOptionIndex();
const selectedOptionIndex = this.findSelectedOptionIndex(true);
if (selectedOptionIndex !== -1 || modelValue === undefined || modelValue === null || this.editable) {
this.selectedOption = visibleOptions[selectedOptionIndex];
this.cd.markForCheck();
Expand Down Expand Up @@ -1125,8 +1125,8 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
return this.autoDisplayFirst && !this.placeholder() && (this.modelValue() === undefined || this.modelValue() === null) && !this.editable && this.options && this.options.length;
}

isSelected(option) {
return this.isValidOption(option) && ObjectUtils.equals(this.modelValue(), this.getOptionValue(option), this.equalityKey());
isSelected(option, includeDisabledOption = false) {
return this.isValidOption(option, includeDisabledOption) && ObjectUtils.equals(this.modelValue(), this.getOptionValue(option), this.equalityKey());
}

ngAfterViewInit() {
Expand Down Expand Up @@ -1523,8 +1523,8 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
return this.modelValue() !== undefined;
}

isValidSelectedOption(option) {
return this.isValidOption(option) && this.isSelected(option);
isValidSelectedOption(option, includeDisabledOption = false) {
return this.isValidOption(option, includeDisabledOption) && this.isSelected(option, includeDisabledOption);
}

equalityKey() {
Expand All @@ -1540,8 +1540,8 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
return this.visibleOptions().findIndex((option) => this.isValidOption(option));
}

findSelectedOptionIndex() {
return this.hasSelectedOption() ? this.visibleOptions().findIndex((option) => this.isValidSelectedOption(option)) : -1;
findSelectedOptionIndex(includeDisabledOptions = false) {
return this.hasSelectedOption() ? this.visibleOptions().findIndex((option) => this.isValidSelectedOption(option, includeDisabledOptions)) : -1;
}

findNextOptionIndex(index) {
Expand Down Expand Up @@ -1570,8 +1570,8 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
return selectedIndex < 0 ? this.findLastOptionIndex() : selectedIndex;
}

isValidOption(option) {
return option !== undefined && option !== null && !(this.isOptionDisabled(option) || this.isOptionGroup(option));
isValidOption(option, includeDisabledOption = false) {
return option !== undefined && option !== null && !((!includeDisabledOption && this.isOptionDisabled(option)) || this.isOptionGroup(option));
}

isOptionGroup(option) {
Expand Down Expand Up @@ -1774,7 +1774,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
}

onFilterInputChange(event: Event | any): void {
let value: string = (event.target as HTMLInputElement).value
let value: string = (event.target as HTMLInputElement).value;
this._filterValue.set(value);
this.focusedOptionIndex.set(-1);
this.onFilter.emit({ originalEvent: event, filter: this._filterValue() });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AppDocSectionNavComponent implements OnInit, OnDestroy {
return [...Array.from(this.document.querySelectorAll(':is(h1,h2,h3).doc-section-label'))].filter((el: any) => DomHandler.isVisible(el));
}

onScroll() {
onScroll() {
if (isPlatformBrowser(this.platformId) && this.nav) {
if (!this.isScrollBlocked) {
this.zone.run(() => {
Expand Down

0 comments on commit a1118c9

Please sign in to comment.