Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop): clear the area selection once a screenshot captures it

Aatman Jain (AJ)92c6864bda6a
diff --git a/apps/desktop/src/components/Cropper.tsx b/apps/desktop/src/components/Cropper.tsx
index 411eeb3df..5ae71bbb4 100644
--- a/apps/desktop/src/components/Cropper.tsx
+++ b/apps/desktop/src/components/Cropper.tsx
@@ -223,7 +223,7 @@ function slideBoundsIntoContainer(
export type CropperRef = {
fill: () => void;
- reset: () => void;
+ reset: (options?: { animate?: boolean }) => void;
setCropProperty: (field: keyof CropBounds, value: number) => void;
setCrop: (
value: CropBounds | ((b: CropBounds) => CropBounds),
@@ -617,9 +617,14 @@ export function Cropper(
if (props.ref) {
const cropperRef: CropperRef = {
- reset: () => {
+ reset: (options) => {
const bounds = computeInitialBounds();
- setRawBoundsAndAnimate(bounds);
+ if (options?.animate === false) {
+ stopAnimation();
+ setRawBoundsConstraining(bounds);
+ } else {
+ setRawBoundsAndAnimate(bounds);
+ }
setAspectState("snapped", null);
},
fill,
diff --git a/apps/desktop/src/routes/target-select-overlay.tsx b/apps/desktop/src/routes/target-select-overlay.tsx
index bf7816745..764128b87 100644
--- a/apps/desktop/src/routes/target-select-overlay.tsx
+++ b/apps/desktop/src/routes/target-select-overlay.tsx
@@ -1299,6 +1299,14 @@ function Inner() {
try {
await commands.suspendTargetSelectOverlays();
+ // The overlay webview is hidden rather than closed (only
+ // Windows closes it, and only after a successful capture), and
+ // the next picker session reuses it with targetMode still
+ // "area", so this branch stays mounted. Suspending ended this
+ // session; drop its selection so the next area screenshot
+ // starts empty: https://github.com/CapSoftware/Cap/issues/2432
+ setInitialAreaBounds(undefined);
+ cropperRef?.reset({ animate: false });
await new Promise((resolve) => setTimeout(resolve, 50));
const path = await commands.takeScreenshot(target);