Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Topology "copy to clipboard" action fails #1167

Closed
andrewazores opened this issue Nov 28, 2023 · 8 comments
Closed

[Bug] Topology "copy to clipboard" action fails #1167

andrewazores opened this issue Nov 28, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@andrewazores
Copy link
Member

Current Behavior

Clicking the "copy to clipboard" icon on the Topology > Create Custom Target view fails. An error appears in the console and the text is not copied into the system clipboard.

Expected Behavior

There should be no error in the console and the text should be copied into the clipboard.

Steps To Reproduce

  1. Run Cryostat 2.5.0-snapshot
  2. Go to Topology > Create Custom Target
  3. Click the clipboard icon to copy the example JMX URL

Environment

Cryostat 2.5.0

In Cryostat 2.4.0(-pre) this works as expected.

Anything else?

Screenshot_2023-11-28_14-07-20

@andrewazores andrewazores added the bug Something isn't working label Nov 28, 2023
@tthvo
Copy link
Member

tthvo commented Nov 28, 2023

Sorry, I have been checking this out and seems to be working: directly with cryostat server and via yarn start:dev.

image

@tthvo
Copy link
Member

tthvo commented Nov 28, 2023

Maybe, it is some browser restrictions that prevents clipboard from being available?

@andrewazores
Copy link
Member Author

andrewazores commented Nov 28, 2023

Hmm. Okay, I'll check again with another browser or with extensions disabled or something. Could just be on my end. Maybe I tested on version in a regular browser window and the other in private/incognito with no extensions and that's where the difference came in.

@andrewazores
Copy link
Member Author

Hmm, I can't reproduce this anymore either. It probably was just something with my browser setup at the time.

@andrewazores
Copy link
Member Author

Hang on, actually, I can reproduce it by building and smoketesting cryostat3. That's using what should be the same cryostat-web version as 2.5.0-snapshot however, so I'm not sure where the difference lies. I wonder if the 3.0 build is doing something wrong with the dependency lockfile.

@andrewazores andrewazores reopened this Nov 29, 2023
@tthvo
Copy link
Member

tthvo commented Nov 29, 2023

Ahh right I saw the same thing. I suppose this is the issue: https://stackoverflow.com/questions/51805395/navigator-clipboard-is-undefined

This requires a secure origin — either HTTPS or localhost (or disabled by running Chrome with a flag). Just like for ServiceWorker, this state is indicated by the presence or absence of the property on the navigator object.

https://developers.google.com/web/updates/2018/03/clipboardapi

This is noted in the spec with [SecureContext] on the interface: https://w3c.github.io/clipboard-apis/#dom-navigator-clipboard

You can check the state of window.isSecureContext to learn if that's the reason a feature is unavailable. Secure contexts | MDN

When I tried with http://localhost:8181, it worked fine. However, http://cryostat3:8181 failed as in the issue.

@tthvo
Copy link
Member

tthvo commented Nov 29, 2023

For cryostat3 hostname over HTTP:

Screenshot from 2023-11-29 10-17-23

For localhost hostname over HTTP:

image

@andrewazores
Copy link
Member Author

Ahh, nice find, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants