{"record":{"id":"1c7d355097df7366","repo":"angular/components","slug":"cdkselection-multiple-selection-not-enabled","errorCode":null,"errorMessage":"CdkSelection: multiple selection not enabled","messagePattern":"CdkSelection: multiple selection not enabled","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cdk-experimental/selection/selection.ts","lineNumber":159,"sourceCode":"  toggleSelection(value: T, index?: number) {\n    if (!!this.trackByFn && index == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('CdkSelection: index required when trackBy is used');\n    }\n\n    if (this.isSelected(value, index)) {\n      this._selection.deselect({value, index});\n    } else {\n      this._selection.select({value, index});\n    }\n  }\n\n  /**\n   * Toggles select-all. If no value is selected, select all values. If all values or some of the\n   * values are selected, de-select all values.\n   */\n  toggleSelectAll() {\n    if (!this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('CdkSelection: multiple selection not enabled');\n    }\n\n    if (this.selectAllState === 'none') {\n      this._selectAll();\n    } else {\n      this._clearAll();\n    }\n  }\n\n  /** Checks whether a value is selected. `index` is required if `trackBy` is used. */\n  isSelected(value: T, index?: number) {\n    if (!!this.trackByFn && index == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('CdkSelection: index required when trackBy is used');\n    }\n\n    return this._selection.isSelected({value, index});\n  }\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk-experimental/selection/selection.ts#L141-L177","documentation":"CdkSelection.toggleSelectAll only makes sense when multiple selection is enabled; in single-selection mode 'select all' is meaningless, so the method throws this dev-mode error whenever _multiple is false. Enabling it requires the CdkSelection (and underlying SelectionSet) to be in multiple mode.","triggerScenarios":"Calling toggleSelectAll() on a CdkSelection without multiple: true (e.g., no [multiple] input / SelectionSet not created with multiple). A select-all button wired to a single-select list.","commonSituations":"Reusing a select-all toolbar component against a single-select list; forgetting to propagate multiple to both the CdkSelection input and its SelectionSet; copy-paste from a multi-select example.","solutions":["Set multiple on the CdkSelection (and construct its SelectionSet with { multiple: true }).","Hide or disable the select-all control when multiple selection is off.","Replace the call with toggleSelection(value, index) for single-select toggling."],"exampleFix":"<!-- before -->\n<cdk-selection [dataSource]=\"rows\"><button (click)=\"sel.toggleSelectAll()\">All</button>\n\n<!-- after -->\n<cdk-selection [dataSource]=\"rows\" multiple> ... ","handlingStrategy":"validation","validationCode":"if (!selectionMultiple) {\n  // hide/disable select-all instead of calling it\n  showSelectAllButton = false;\n} else {\n  selection.toggleSelectAll();\n}","typeGuard":"function supportsSelectAll(sel: { _multiple?: boolean }): boolean {\n  return sel._multiple === true;\n}","tryCatchPattern":"try {\n  selection.toggleSelectAll();\n} catch (e) {\n  if ((e as Error).message.includes('multiple selection not enabled')) {\n    selection.toggleSelection(currentValue, 0);\n  } else throw e;\n}","preventionTips":["Enable multiple on CdkSelection before rendering any select-all UI.","Conditionally render select-all controls based on the multiple flag.","Keep CdkSelection's multiple flag in sync with its underlying SelectionSet."],"tags":["angular","cdk","selection","select-all","dev-mode-assertion"],"backgroundTag":"single-selection-mode-multiple-values","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}