Skip to content

Clipboard: copy method returns false inside observable #24143

Open

Description

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

this.clipBoard.copy('copy text') is not working in Chrome. It always return false when its inside the observable and the response of the observable takes more time. This same scenario works fine when I tested in IE. There are not warnings/error in browser console.

I have also tried with beginCopy/copy/destroy methods but it didnt get copied and no errors in browser console.

There are other places I have used the copy method inside observable and it works fine. The difference in this observable is it returns the observable response faster than the one which doesn't work.

Reproduction

 onSubmitClick() {
    this.statusMessage = 'Processing, please wait...';
          const inputParam = new UIInputVO();
          this.service.generateOutput('inputType', inputParam).subscribe(
            (response: any) => {
              this.statusMessage = response.resultMsg;
              this.txtOutputList = response.txtOutputInfo;
              this.clipBoard.copy(response.windowsPath);
              if (!this.btndisabled) {
                  setTimeout(() => {
                      // this will make the execution after the above boolean has changed
                      this.submitbtn.nativeElement.focus();
                  }, 0);
              }
            }
          );
  }

Expected Behavior

It should copy to user clipboard

Actual Behavior

not copied the string passed to copy method

Environment

  • Angular:9.1.12
  • CDK/Material:9.2.4
  • Browser(s): Chrome - Version 96.0.4664.110 (
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: cdk/clipboardneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions