MCPcopy Index your code
hub / github.com/angular/components / _handleInputClick

Method _handleInputClick

src/material/checkbox/checkbox.ts:408–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

406 }
407
408 protected _handleInputClick() {
409 const clickAction = this._options?.clickAction;
410
411 // If resetIndeterminate is false, and the current state is indeterminate, do nothing on click
412 if (!this.disabled && clickAction !== 'noop') {
413 // When user manually click on the checkbox, `indeterminate` is set to false.
414 if (this.indeterminate && clickAction !== 'check') {
415 Promise.resolve().then(() => {
416 this._indeterminate.set(false);
417 this.indeterminateChange.emit(false);
418 });
419 }
420
421 this._checked = !this._checked;
422 this._transitionCheckState(
423 this._checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked,
424 );
425
426 // Emit our custom change event if the native input emitted one.
427 // It is important to only emit it, if the native input triggered one, because
428 // we don't want to trigger a change event, when the `checked` variable changes for example.
429 this._emitChangeEvent();
430 } else if (
431 (this.disabled && this.disabledInteractive) ||
432 (!this.disabled && clickAction === 'noop')
433 ) {
434 // Reset native input when clicked with noop. The native checkbox becomes checked after
435 // click, reset it to be align with `checked` value of `mat-checkbox`.
436 this._inputElement.nativeElement.checked = this.checked;
437 this._inputElement.nativeElement.indeterminate = this.indeterminate;
438 }
439 }
440
441 _onInteractionEvent(event: Event) {
442 // We always have to stop propagation on the change event.

Callers 2

_onInputClickMethod · 0.95
_onTouchTargetClickMethod · 0.95

Calls 4

_transitionCheckStateMethod · 0.95
_emitChangeEventMethod · 0.95
resolveMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected