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

ZERO WIDTH SPACE (U+200B) in path copied if selection is not exact #7513

Closed
MingweiSamuel opened this issue Sep 17, 2021 · 4 comments · Fixed by #7516
Closed

ZERO WIDTH SPACE (U+200B) in path copied if selection is not exact #7513

MingweiSamuel opened this issue Sep 17, 2021 · 4 comments · Fixed by #7516

Comments

@MingweiSamuel
Copy link
Contributor

Q&A (please complete the following information)

  • OS: Win 10
  • Browser: Firefox
  • Version: 92.0
  • Method of installation: dist/
  • Swagger-UI version: v3.24.2
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]

Describe the bug you're encountering

If you drag to select the path, but select a little bit too far, the zero-width space removal doesn't happen, and you copy a bunch of zero-width spaces into your code to cause invisible bugs.

To reproduce...

Steps to reproduce the behavior:

  1. Start selecting the path text from right to left.
  2. Drag slightly further than the start of the text.
  3. Copy

Screenshots

image
Will copy zero width spaces (on left and in middle of path).

If you very carefully stop at the start of the text things will be OK:
image
(OK)

Cause

Caused by #5184

The PR above injects zero width spaces into the path, but includes an onCopyCapture function which is triggered when the user copies, which removes all zero width spaces from the copied text. However that event is only triggered if the selection is only on the path <span>. In reality, users will often drag a little further to make sure all the characters are selected, but this (for some reason) means the onCopyCapture is not triggered and ZERO WIDTH SPACEs are copied.

Fix

<wbr> should be used instead, which requires no onCopyCapture faffing: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr

@MingweiSamuel
Copy link
Contributor Author

MingweiSamuel commented Sep 17, 2021

Another side-effect of #5184 is that if you select text like this:
image
What actually gets copied is /data-store/v1/install-dir, whether you want that or not.

@char0n
Copy link
Member

char0n commented Sep 17, 2021

@MingweiSamuel nice catch.

Are you willing to entertain a PR with the fix?

@MingweiSamuel
Copy link
Contributor Author

Sure

@char0n
Copy link
Member

char0n commented Sep 17, 2021

Great! Looking forward

MingweiSamuel added a commit to MingweiSamuel/swagger-ui that referenced this issue Sep 17, 2021
…#7516)

- Use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments in
  operation-summary-path.jsx
- Remove no-longer-needed onCopyCapture listener which previously
  stripped ZWSPs

Closes swagger-api#7513
MingweiSamuel added a commit to MingweiSamuel/swagger-ui that referenced this issue Sep 17, 2021
- Use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments in
  operation-summary-path.jsx
- Remove no-longer-needed onCopyCapture listener which previously
  stripped ZWSPs

Closes swagger-api#7513
MingweiSamuel added a commit to MingweiSamuel/swagger-ui that referenced this issue Sep 17, 2021
- Use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments in
  operation-summary-path.jsx
- Remove no-longer-needed onCopyCapture listener which previously
  stripped ZWSPs

Closes swagger-api#7513
MingweiSamuel added a commit to MingweiSamuel/swagger-ui that referenced this issue Sep 19, 2021
- Use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments in
  operation-summary-path.jsx
- Remove no-longer-needed onCopyCapture listener which previously
  stripped ZWSPs

Closes swagger-api#7513
MingweiSamuel added a commit to MingweiSamuel/swagger-ui that referenced this issue Sep 22, 2021
- Use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments in
  operation-summary-path.jsx
- Remove no-longer-needed onCopyCapture listener which previously
  stripped ZWSPs
- Update's deep-link.jsx's `text` prop type to accept `PropType.node`
  to allow the above.

Closes swagger-api#7513
MingweiSamuel added a commit to MingweiSamuel/swagger-ui that referenced this issue Sep 22, 2021
- Use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments in
  operation-summary-path.jsx
- Remove no-longer-needed onCopyCapture listener which previously
  stripped ZWSPs
- Update's deep-link.jsx's `text` prop type to accept `PropType.node`
  to allow the above.

Closes swagger-api#7513
char0n pushed a commit that referenced this issue Sep 30, 2021
- use <wbr> instead of ZERO-WIDTH SPACE (U+200B) to break segments 
- remove no-longer-needed onCopyCapture listener which previously  stripped ZWSPs
- update's deep-link.jsx's `text` prop type to accept `PropType.node`  to allow the above.

Closes #7513
Co-authored-by: Vladimir Gorej <vladimir.gorej@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants