Description:
The afterSetValue method in Neo.form.field.ComboBox contains a redundant call to selectionModel?.deselect(oldValue) when singleSelect is enabled.
Current Code (src/form/field/ComboBox.mjs, afterSetValue method):
if (me._picker?.isVisible) {
let selectionModel = me.list?.selectionModel;
if (value) {
oldValue && selectionModel?.deselect(oldValue);
selectionModel?.select(value)
} else {
selectionModel.deselectAll()
}
}
Problem:
When selectionModel.singleSelect is true (which is the default for ComboBox), the selectionModel.select(value) method itself handles the deselection of any previously selected item. Therefore, explicitly calling selectionModel?.deselect(oldValue) before select(value) is unnecessary. This leads to:
- Redundant method calls.
- Potentially unnecessary
view.update() calls and selectionChange events from the selectionModel.
Proposed Change:
Remove the line oldValue && selectionModel?.deselect(oldValue); from the afterSetValue method in src/form/field/ComboBox.mjs.
Reasoning:
The selectionModel.select() method, when singleSelect is true, is designed to ensure only one item is selected. It will internally deselect any existing selection before applying the new one. Removing the redundant deselect call will streamline the selection logic, improve efficiency, and prevent potential unnecessary event emissions from the selectionModel.
Description:
The
afterSetValuemethod inNeo.form.field.ComboBoxcontains a redundant call toselectionModel?.deselect(oldValue)whensingleSelectis enabled.Current Code (src/form/field/ComboBox.mjs, afterSetValue method):
if (me._picker?.isVisible) { let selectionModel = me.list?.selectionModel; if (value) { oldValue && selectionModel?.deselect(oldValue); // <-- This line is redundant when singleSelect is true selectionModel?.select(value) } else { selectionModel.deselectAll() } }Problem: When
selectionModel.singleSelectistrue(which is the default forComboBox), theselectionModel.select(value)method itself handles the deselection of any previously selected item. Therefore, explicitly callingselectionModel?.deselect(oldValue)beforeselect(value)is unnecessary. This leads to:view.update()calls andselectionChangeevents from theselectionModel.Proposed Change: Remove the line
oldValue && selectionModel?.deselect(oldValue);from theafterSetValuemethod insrc/form/field/ComboBox.mjs.Reasoning: The
selectionModel.select()method, whensingleSelectis true, is designed to ensure only one item is selected. It will internally deselect any existing selection before applying the new one. Removing the redundantdeselectcall will streamline the selection logic, improve efficiency, and prevent potential unnecessary event emissions from theselectionModel.