Skip to content

Commit

Permalink
Selected options in Content Selector get deselected on dropdown scroll
Browse files Browse the repository at this point in the history
…#3305

- BaseRichComboBox: comboBox.addOption doesn't select item that is supposed to be selected
- DropdownList: navigating to the first selected row only if dropdown was not open yet
  • Loading branch information
ashklianko committed Oct 16, 2023
1 parent fd8c00b commit 3e429c4
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 @@ -117,16 +117,21 @@ export class DropdownList<OPTION_DISPLAY_VALUE> {
}

showDropdown(selectedOptions?: Option<OPTION_DISPLAY_VALUE>[], noOptionsText?: string) {
const isShown: boolean = this.isDropdownShown();

if (this.hasOptions()) {
this.emptyDropdown.hide();
this.dropdownGrid.show();
this.dropdownGrid.adjustGridHeight();

if (selectedOptions) {
this.dropdownGrid.markSelections(selectedOptions);
if (selectedOptions.length > 0) {
this.dropdownGrid.markReadOnly(selectedOptions);
this.navigateToRowIfNotActive(selectedOptions[0]);

if (!isShown) {
this.navigateToRowIfNotActive(selectedOptions[0]);
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,26 +418,12 @@ export class BaseRichComboBox<OPTION_DATA_TYPE, LOADER_DATA_TYPE>
}
}

private handleLoadedData(event: LoadedDataEvent<LOADER_DATA_TYPE>) {
private handleLoadedData(event: LoadedDataEvent<LOADER_DATA_TYPE>): Q.Promise<void> {
this.errorContainer.hide();
const optionCount: number = this.getOptionCount();

return this.createOptions(event.getData().map(this.loadedItemToDisplayValue.bind(this))).then(
(options: Option<OPTION_DATA_TYPE>[]) => {
let appendOptions: boolean = false;

if (event.isPostLoad() && optionCount > 0) {
const lastOption: Option<OPTION_DATA_TYPE> = this.getOptionByRow(optionCount - 1);
appendOptions = options.length > optionCount && options[optionCount - 1].getValue() === lastOption.getValue();
}

if (appendOptions) {
for (let i: number = optionCount; i < options.length; i++) {
this.comboBox.addOption(options[i]);
}
} else {
this.comboBox.setOptions(options, event.isPostLoad());
}

this.comboBox.setOptions(options, event.isPostLoad());
this.notifyLoaded(options.map((option) => option.getDisplayValue()), event.isPostLoad());
return;
});
Expand Down

0 comments on commit 3e429c4

Please sign in to comment.