Fix Sketch clearing bug (#3047)

* bug fix

* changelog

* undo fix
This commit is contained in:
Dawood Khan 2023-01-30 11:24:11 -05:00 committed by GitHub
parent 9ccfef0542
commit 6c8ed19ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -65,6 +65,7 @@ to log in. Some browsers disable third party cookies by default (Safari, Chrome
* Fixes bug where app would crash if the `file_types` parameter of `gr.File` or `gr.UploadButton` was not a list by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3048](https://github.com/gradio-app/gradio/pull/3048)
* Ensure CSS mounts correctly regardless of how many Gradio instances are on the page [@pngwn](https://github.com/pngwn) in [PR 3059](https://github.com/gradio-app/gradio/pull/3059).
* Fix bug where input component was not hidden in the frontend for `UploadButton` by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3053](https://github.com/gradio-app/gradio/pull/3053)
* Fixes issue where after clicking submit or undo, the sketch output wouldn't clear. [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3047](https://github.com/gradio-app/gradio/pull/3047)
* Ensure spaces embedded via the web component always use the correct URLs for server requests and change ports for testing to avoid strange collisions when users are working with embedded apps locally by [@pngwn](https://github.com/pngwn) in [PR 3065](https://github.com/gradio-app/gradio/pull/3065)
* Preserve selected image of Gallery through updated by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3061](https://github.com/gradio-app/gradio/pull/3061)
* Fix bug where auth was not respected on HF spaces by [@freddyaboulton](https://github.com/freddyaboulton) and [@aliabid94](https://github.com/aliabid94) in [PR 3049](https://github.com/gradio-app/gradio/pull/3049)

View File

@ -103,7 +103,7 @@
container_height = element.getBoundingClientRect().height;
}
async function handle_mask_clear() {
async function handle_sketch_clear() {
sketch.clear();
await tick();
value = null;
@ -214,7 +214,7 @@
/>
<ModifySketch
on:undo={() => sketch.undo()}
on:clear={handle_mask_clear}
on:clear={handle_sketch_clear}
/>
{#if tool === "color-sketch" || tool === "sketch"}
<SketchSettings
@ -238,7 +238,7 @@
{:else if source === "canvas"}
<ModifySketch
on:undo={() => sketch.undo()}
on:clear={() => sketch.clear()}
on:clear={handle_sketch_clear}
/>
{#if tool === "color-sketch"}
<SketchSettings
@ -255,6 +255,7 @@
bind:brush_color
bind:this={sketch}
on:change={handle_save}
on:clear={handle_sketch_clear}
{mode}
width={img_width || max_width}
height={img_height || max_height}
@ -314,7 +315,7 @@
/>
<ModifySketch
on:undo={() => sketch.undo()}
on:clear={handle_mask_clear}
on:clear={handle_sketch_clear}
/>
{#if tool === "color-sketch" || tool === "sketch"}
<SketchSettings

View File

@ -206,6 +206,9 @@
lines = _lines;
}
if (lines.length == 0) {
dispatch("clear");
}
trigger_on_change();
}