Skip to content

Commit 796c405

Browse files
committed
bug: Missed updating a place that checks MAX_SELECTIONS to use the configured value
1 parent f15f926 commit 796c405

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/cfpb-forms/src/organisms/MultiselectModel.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ function stringMatch(x, y) {
3434
function MultiselectModel(options, name, config) {
3535
const _options = options;
3636
const _name = name;
37+
const _max = config?.maxSelections || MAX_SELECTIONS;
38+
3739
let _optionsData = [];
3840

3941
let _selectedIndices = [];
@@ -60,7 +62,6 @@ function MultiselectModel(options, name, config) {
6062
* True if the maximum number of options are checked, false otherwise.
6163
*/
6264
function isAtMaxSelections() {
63-
const _max = config?.maxSelections || MAX_SELECTIONS;
6465
return _selectedIndices.length >= _max;
6566
}
6667

@@ -110,10 +111,7 @@ function MultiselectModel(options, name, config) {
110111
function toggleOption(index) {
111112
_optionsData[index].checked = !_optionsData[index].checked;
112113

113-
if (
114-
_selectedIndices.length < MAX_SELECTIONS &&
115-
_optionsData[index].checked
116-
) {
114+
if (_selectedIndices.length < _max && _optionsData[index].checked) {
117115
_selectedIndices.push(index);
118116
_selectedIndices.sort();
119117

0 commit comments

Comments
 (0)