Skip to content

Commit d94695d

Browse files
authored
feat(feedback): Screenshots don't resize after cropping (#12481)
Screenshots will no longer become larger to fit the screenshot area after being cropped, instead it would remain the same size. The image quality of the screenshot goes down if the image is cropped too much. This could help make small crops a bit more readable. Before: <img width="1716" alt="Select a speeder" src="https://github.com/getsentry/sentry-javascript/assets/55311782/c99af75e-4cfc-41e2-86bc-f0232962f91a"> After: <img width="1716" alt="Pasted Graphic" src="https://github.com/getsentry/sentry-javascript/assets/55311782/1bd2b1ef-ef8c-4b6d-90fa-ae444141ede0"> Relates to #12329
1 parent 60dad34 commit d94695d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

packages/feedback/src/modal/components/Dialog.css.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,12 @@ const FORM = `
100100
}
101101
102102
.form__right {
103-
width: var(--form-width, 272px);
103+
min-width: var(--form-width, 272px);
104104
display: flex;
105105
overflow: auto;
106106
flex-direction: column;
107107
justify-content: space-between;
108108
gap: 20px;
109-
flex: 1 0 auto;
110109
}
111110
112111
@media (max-width: 600px) {

packages/feedback/src/screenshot/components/ScreenshotEditor.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
9494
if (cropButton) {
9595
cropButton.style.width = `${imageDimensions.width}px`;
9696
cropButton.style.height = `${imageDimensions.height}px`;
97-
cropButton.style.left = `${imageDimensions.x}px`;
98-
cropButton.style.top = `${imageDimensions.y}px`;
9997
}
10098

10199
setCroppingRect({ startX: 0, startY: 0, endX: imageDimensions.width, endY: imageDimensions.height });
@@ -212,6 +210,8 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
212210
ctx.clearRect(0, 0, imageBuffer.width, imageBuffer.height);
213211
imageBuffer.width = cutoutCanvas.width;
214212
imageBuffer.height = cutoutCanvas.height;
213+
imageBuffer.style.width = `${cutoutCanvas.width}px`;
214+
imageBuffer.style.height = `${cutoutCanvas.height}px`;
215215
ctx.drawImage(cutoutCanvas, 0, 0);
216216
resizeCropper();
217217
}
@@ -229,6 +229,8 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
229229
}
230230
imageBuffer.width = imageSource.videoWidth;
231231
imageBuffer.height = imageSource.videoHeight;
232+
imageBuffer.style.width = '100%';
233+
imageBuffer.style.height = '100%';
232234
context.drawImage(imageSource, 0, 0);
233235
},
234236
[imageBuffer],
@@ -249,7 +251,7 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
249251
<div class="editor">
250252
<style dangerouslySetInnerHTML={styles} />
251253
<div class="editor__canvas-container" ref={canvasContainerRef}>
252-
<div class="editor__crop-container" style={{ position: 'absolute' }} ref={cropContainerRef}>
254+
<div class="editor__crop-container" style={{ position: 'absolute', zIndex: 1 }} ref={cropContainerRef}>
253255
<canvas style={{ position: 'absolute' }} ref={croppingRef}></canvas>
254256
<CropCorner
255257
left={croppingRect.startX - CROP_BUTTON_BORDER}

packages/feedback/src/screenshot/components/ScreenshotInput.css.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ export function createScreenshotInputStyles(): HTMLStyleElement {
3737
width: 100%;
3838
height: 100%;
3939
position: relative;
40+
display: flex;
41+
align-items: center;
42+
justify-content: center;
4043
}
4144
4245
.editor__canvas-container canvas {
43-
width: 100%;
44-
height: 100%;
4546
object-fit: contain;
47+
position: relative;
4648
}
4749
4850
.editor__crop-btn-group {

0 commit comments

Comments
 (0)