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

fix(frontend): Better CopyToClipboardInline typing #18723

Merged
merged 7 commits into from
Nov 17, 2023

Conversation

Twixes
Copy link
Member

@Twixes Twixes commented Nov 17, 2023

Problem

Throwing errors rarely is a good idea in React components… yet that's what I did in #18662 within CopyToClipboardInline to prevent un-copyable values from being presented as copyable (primarily objects, whose String() representation is "[object Object]"). This did prevent that, but also crashed the offending scene, which is too drastic.

Changes

This PR does the right thing, which is narrowing down the component's type to prevent this at compile time. Mostly, because we still allow an implicit conversion from any-typed values, which can be bad. That's PropertiesTable, which I looked at manually – it now allows copying any value, because non-strings we can easily JSON.stringify().

How did you test this code?

Added visual regression test.

@Twixes Twixes requested review from liyiy and a team November 17, 2023 17:50
@Twixes Twixes force-pushed the fix-copy-inline-typing branch from 101b948 to 4e74462 Compare November 17, 2023 17:52
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

github-actions bot commented Nov 17, 2023

Size Change: 0 B

Total Size: 2.01 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 2.01 MB

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely stuff!

@Twixes Twixes changed the title fix(frontend): Better CopyToClipboardInline typig instead of errors fix(frontend): Better CopyToClipboardInline typing instead of errors Nov 17, 2023
@Twixes Twixes changed the title fix(frontend): Better CopyToClipboardInline typing instead of errors fix(frontend): Better CopyToClipboardInline typing Nov 17, 2023
@Twixes Twixes merged commit e2df3a1 into master Nov 17, 2023
73 checks passed
@Twixes Twixes deleted the fix-copy-inline-typing branch November 17, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants