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

ref(feedback): Refactor screenshot editor into multiple files #15362

Merged
merged 6 commits into from
Feb 12, 2025

Conversation

c298lee
Copy link
Member

@c298lee c298lee commented Feb 10, 2025

We are splitting up screenshot editor into 3 additional parts: cropping, annotations, toolbar

@c298lee c298lee requested a review from a team as a code owner February 10, 2025 21:30
@c298lee c298lee requested a review from ryan953 February 10, 2025 21:31
Copy link
Contributor

github-actions bot commented Feb 10, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.95 KB - -
@sentry/browser - with treeshaking flags 22.73 KB - -
@sentry/browser (incl. Tracing) 35.88 KB - -
@sentry/browser (incl. Tracing, Replay) 72.88 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.38 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 77.13 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 90.04 KB +0.17% +150 B 🔺
@sentry/browser (incl. Feedback) 40.06 KB +0.39% +157 B 🔺
@sentry/browser (incl. sendFeedback) 27.58 KB +0.01% +1 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.38 KB +0.01% +2 B 🔺
@sentry/react 24.78 KB - -
@sentry/react (incl. Tracing) 37.78 KB - -
@sentry/vue 27.14 KB - -
@sentry/vue (incl. Tracing) 37.59 KB - -
@sentry/svelte 22.99 KB - -
CDN Bundle 24.17 KB - -
CDN Bundle (incl. Tracing) 35.92 KB - -
CDN Bundle (incl. Tracing, Replay) 70.75 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 75.91 KB - -
CDN Bundle - uncompressed 70.64 KB - -
CDN Bundle (incl. Tracing) - uncompressed 106.73 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.95 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.51 KB - -
@sentry/nextjs (client) 38.75 KB - -
@sentry/sveltekit (client) 36.32 KB - -
@sentry/node 156.33 KB - -
@sentry/node - without tracing 97.31 KB -0.01% -2 B 🔽
@sentry/aws-serverless 106.82 KB - -

View base workflow run


return function ScreenshotEditor({ onError }: Props): VNode {
const styles = hooks.useMemo(() => ({ __html: createScreenshotInputStyles(options.styleNonce).innerText }), []);

const canvasContainerRef = hooks.useRef<HTMLDivElement>(null);
const cropContainerRef = hooks.useRef<HTMLDivElement>(null);
const croppingRef = hooks.useRef<HTMLCanvasElement>(null);
const annotatingRef = hooks.useRef<HTMLCanvasElement>(null);
Copy link
Member

Choose a reason for hiding this comment

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

What if this useRef call was just inside Annotations.tsx?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's used in screenshot editor when resizing

Copy link
Member

Choose a reason for hiding this comment

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

oh i missed that. i'll take another look. it's a non-blocking kind of thing too

Copy link

codecov bot commented Feb 10, 2025

❌ 416 Tests Failed:

Tests completed Failed Passed Skipped
2282 416 1866 302
View the top 3 failed test(s) by shortest run time
tracing/metrics/handlers-lcp/test.ts should capture metrics for LCP instrumentation handlers
Stack Traces | 0.002s run time
test.ts:10:11 should capture metrics for LCP instrumentation handlers
tracing/metrics/web-vitals/test.ts paint web vitals values are greater than TTFB
Stack Traces | 0.002s run time
test.ts:15:11 paint web vitals values are greater than TTFB
tracing/metrics/pageload-browser-spans/test.ts should add browser-related spans to pageload transaction
Stack Traces | 0.003s run time
test.ts:7:11 should add browser-related spans to pageload transaction

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

setCroppingRect={setCroppingRect}
resize={resize}
/>
<Annotations action={action} imageBuffer={imageBuffer} annotatingRef={annotatingRef} />
Copy link
Member

@ryan953 ryan953 Feb 10, 2025

Choose a reason for hiding this comment

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

Would it work if this was like:

Suggested change
<Annotations action={action} imageBuffer={imageBuffer} annotatingRef={annotatingRef} />
{action === 'annotate' ? <Annotations imageBuffer={imageBuffer} annotatingRef={annotatingRef} /> : null}

same for options._experiments.annotations || action === 'crop' ? <Crop> : null

Copy link
Member Author

Choose a reason for hiding this comment

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

no it does not :(

Copy link
Member

@ryan953 ryan953 left a comment

Choose a reason for hiding this comment

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

splitting into multiple files is a big help. We could probably do something about the number of props, but i'd need too look more closely first.

This works and is an improvement, so i'm all for 🚢

@c298lee c298lee requested a review from billyvg February 11, 2025 20:03
Comment on lines +101 to +103
if (action !== 'crop') {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

When/why would this component get a non crop action?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's in a useEffect with action as a dependency. This is done so that when you switch from cropping to the annotation tool, the above part of the code will run and clear the rectangle drawn around the image.

<button
class={`editor__tool ${action === 'crop' ? 'editor__tool--active' : ''}`}
onClick={e => {
e.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

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

what's the default behavior that this stops?

(you might need a type="button" if it's submitting a form)

Copy link
Member Author

Choose a reason for hiding this comment

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

it is submitting the form 😬

@c298lee c298lee merged commit 5b665b8 into develop Feb 12, 2025
146 checks passed
@c298lee c298lee deleted the cl/ref-uf branch February 12, 2025 16:16
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.

3 participants