Skip to content

mat-slide-toggle fails to toggle upon mouse click when text is selected elsewhere on form #18269

Closed
@christopher-brown-rcx

Description

@christopher-brown-rcx

Reproduction

Using Chrome, see the following StackBlitz: https://stackblitz.com/edit/angular-1ztoyy

Steps to reproduce:

  1. Upon page load, note that the mat-slide-toggle properly responds to click events by toggling itself.
  2. After 5 seconds, the page is programmatically selecting text in a nearby textbox. (You can also reproduce the issue by manually selecting the text.)
  3. Without clicking anywhere else, try the mat-slide-toggle again, and note that it no longer toggles upon click. (The ripple effect does appear, indicating that it knows it has been clicked. Interestingly, double-click does work.)
  4. Clicking elsewhere on the form restores the expected behavior (presumably because this causes the selected text to be de-selected).

Expected Behavior

The mat-slide-toggle control should toggle its state when clicked.

Actual Behavior

After selecting text in another field, the mat-slide-toggle no longer toggles its state when clicked.

Environment

  • Angular: 9.0.0-rc.9 (This does not appear to be an issue in Angular 8 / Material 8)
  • CDK/Material: Material 9.0.0-rc.8
  • Browser(s): Chrome 79.0.3945.130 (64-bit) (issue does not appear to occur in Edge or Firefox)
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10 x64

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions