{"record":{"id":"68804e93919f5972","repo":"angular/components","slug":"a-matdatepicker-can-only-be-associated-with-a-sing-68804e","errorCode":null,"errorMessage":"A MatDatepicker can only be associated with a single actions row.","messagePattern":"A MatDatepicker can only be associated with a single actions row\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/material/datepicker/datepicker-base.ts","lineNumber":626,"sourceCode":"   * @returns Selection model that the input should hook itself up to.\n   */\n  registerInput(input: C): MatDateSelectionModel<S, D> {\n    if (this.datepickerInput && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('A MatDatepicker can only be associated with a single input.');\n    }\n    this._inputStateChanges.unsubscribe();\n    this.datepickerInput = input;\n    this._inputStateChanges = input.stateChanges.subscribe(() => this.stateChanges.next(undefined));\n    return this._model;\n  }\n\n  /**\n   * Registers a portal containing action buttons with the datepicker.\n   * @param portal Portal to be registered.\n   */\n  registerActions(portal: TemplatePortal): void {\n    if (this._actionsPortal && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('A MatDatepicker can only be associated with a single actions row.');\n    }\n    this._actionsPortal = portal;\n    this._componentRef?.instance._assignActions(portal, true);\n  }\n\n  /**\n   * Removes a portal containing action buttons from the datepicker.\n   * @param portal Portal to be removed.\n   */\n  removeActions(portal: TemplatePortal): void {\n    if (portal === this._actionsPortal) {\n      this._actionsPortal = null;\n      this._componentRef?.instance._assignActions(null, true);\n    }\n  }\n\n  /** Open the calendar. */\n  open(): void {","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/datepicker/datepicker-base.ts#L608-L644","documentation":"registerActions() enforces that a datepicker has at most one mat-datepicker-actions row. If registerActions is called while an actions portal is already assigned, Material throws this dev-mode error.","triggerScenarios":"Declaring <mat-datepicker-actions> twice within one <mat-datepicker>; dynamically attaching an actions portal via registerActions() while one is already registered without unregistering.","commonSituations":"Duplicating the actions block during copy-paste; programmatic code calling registerActions on each open/creation cycle without clearing the previous portal.","solutions":["Keep exactly one <mat-datepicker-actions> inside the datepicker.","Before registering a new portal programmatically, clear or replace the existing _actionsPortal.","Restructure shared datepicker templates so actions are defined once."],"exampleFix":"// before\n<mat-datepicker #picker>\n  <mat-datepicker-actions><button mat-button>OK</button></mat-datepicker-actions>\n  <mat-datepicker-actions><button mat-button>CANCEL</button></mat-datepicker-actions>\n</mat-datepicker>\n\n// after\n<mat-datepicker #picker>\n  <mat-datepicker-actions><button mat-button>OK</button></mat-datepicker-actions>\n</mat-datepicker>","handlingStrategy":"validation","validationCode":"// Assert exactly one actions row per datepicker in shared templates\nfunction countActions(dp: HTMLElement): number {\n  return dp.querySelectorAll('mat-datepicker-actions').length;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define mat-datepicker-actions once per datepicker instance.","When registering portals programmatically, track current portal state before re-registering.","Extract the actions block into a shared component used once per picker."],"tags":["angular-material","datepicker","actions-row","duplicate-registration"],"backgroundTag":"datepicker-shared-instance","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}