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: "Copy" button not working #9094

Closed
Teraskull opened this issue Jul 28, 2023 · 6 comments
Closed

BUG: "Copy" button not working #9094

Teraskull opened this issue Jul 28, 2023 · 6 comments

Comments

@Teraskull
Copy link

The "Copy" button does not work anymore since commit f3ea2a2

image

Verified by running SwaggerUI on the previous commit: be9f944
The "Copy" button works as intended here.

@Teraskull
Copy link
Author

@damian-polewski-sb Can you please verify if your commit is the issue here?

@Teraskull
Copy link
Author

Found a fix.

Replace this:

<div className="view-line-link copy-to-clipboard" title="Copy to clipboard">
<CopyToClipboard text={this.props.textToCopy}>
<CopyIcon />
</CopyToClipboard>
</div>

with:

<CopyToClipboard text={this.props.textToCopy}>
  <div className="view-line-link copy-to-clipboard" title="Copy to clipboard">
    <CopyIcon />
  </div>
</CopyToClipboard>

@damian-polewski-sb
Copy link
Contributor

Hi @Teraskull,
I tested it now and it looks like wrapping svg for copy icon with React functional component in this PR caused an issue with CopyToClipboard wrapping component.

As you suggested, wrapping the whole div in CopyToClipboard solves this issue. I will be raising a PR to apply those changes.

Thanks for your help!

@damian-polewski-sb damian-polewski-sb self-assigned this Jul 31, 2023
@char0n char0n self-assigned this Aug 1, 2023
char0n added a commit that referenced this issue Aug 1, 2023
These arbitrary props will allow to handle
native React element events among other things.

Refs #9094
@char0n
Copy link
Member

char0n commented Aug 1, 2023

Hi everybody,

Thank you for reporting this issue and providing a possible remediation.

I've issued #9106 which superseded #9097.

This issue suggests a solution (which works), but underlying systemic issue wouldn't been addressed. The solution proposed in this issue lacks explanation so we're not sure why it works. If we dig deeper we find out that our new icons plugin SVG components lacks ability to pass arbitrary props, which inhibits it from handling React element native events - like onClick event used by react-copy-to-clipboard. By wrapping SVG icon component into <div> solves this issue as <div> allows arbitrary props passing. But applying this fix is not a solution that addresses the systemic problem, but rather a ad-hoc remediation. Another issues would probably pop up soon.

image

@damian-polewski-sb
Copy link
Contributor

Hi @char0n! First of all, nice job! I agree this approach will be much more elegant and will get rid of any further issues with arbitrary props that might come up.
Thanks!

char0n added a commit that referenced this issue Aug 2, 2023
These arbitrary props will allow to handle
native React element events among other things.

Refs #9094
@char0n
Copy link
Member

char0n commented Aug 2, 2023

Addressed in #9106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants