From f1a1e79be4fc812b3a9c41b179bacb73def10816 Mon Sep 17 00:00:00 2001 From: pngwn Date: Tue, 21 Jun 2022 10:44:30 +0100 Subject: [PATCH] fix autoscroll (#1570) * fix autoscroll * fix formatting Co-authored-by: Ali Abid --- gradio/blocks.py | 2 +- ui/packages/app/src/Blocks.svelte | 6 +++++- .../components/StatusTracker/StatusTracker.svelte | 13 ++++++++++--- ui/packages/app/src/main.ts | 12 ++++++++---- ui/packages/app/src/stores.ts | 1 + 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gradio/blocks.py b/gradio/blocks.py index a20fb6200b..73b8f7beff 100644 --- a/gradio/blocks.py +++ b/gradio/blocks.py @@ -566,7 +566,7 @@ class Blocks(BlockContext): def get_config_file(self): config = { "version": routes.VERSION, - "mode": "blocks", + "mode": self.mode, "dev_mode": self.dev_mode, "components": [], "theme": self.theme, diff --git a/ui/packages/app/src/Blocks.svelte b/ui/packages/app/src/Blocks.svelte index 9c94f57546..e821ed5bb2 100644 --- a/ui/packages/app/src/Blocks.svelte +++ b/ui/packages/app/src/Blocks.svelte @@ -2,7 +2,7 @@ import type { SvelteComponentTyped } from "svelte"; import { onMount } from "svelte"; import { component_map } from "./components/directory"; - import { loading_status } from "./stores"; + import { loading_status, app_state } from "./stores"; import type { LoadingStatus } from "./components/StatusTracker/types"; import { _ } from "svelte-i18n"; @@ -66,6 +66,9 @@ export let css: string; export let is_space: boolean; export let id: number = 0; + export let autoscroll: boolean = false; + + $: app_state.update((s) => ({ ...s, autoscroll })); let rootNode: Component = { id: layout.id, type: "column", props: {} }; components.push(rootNode); @@ -338,6 +341,7 @@ let dependency = dependencies[loading_status.fn_index]; loading_status.scroll_to_output = dependency.scroll_to_output; loading_status.visible = dependency.show_progress; + set_prop(instance_map[id], "loading_status", loading_status); } const inputs_to_update = loading_status.get_inputs_to_update(); diff --git a/ui/packages/app/src/components/StatusTracker/StatusTracker.svelte b/ui/packages/app/src/components/StatusTracker/StatusTracker.svelte index dbd20091d1..8fc6246261 100644 --- a/ui/packages/app/src/components/StatusTracker/StatusTracker.svelte +++ b/ui/packages/app/src/components/StatusTracker/StatusTracker.svelte @@ -5,8 +5,14 @@ let called = false; - async function scroll_into_view(el: HTMLDivElement) { - if (window.__gradio_mode__ === "website") { + async function scroll_into_view( + el: HTMLDivElement, + enable: boolean | null = true + ) { + if ( + window.__gradio_mode__ === "website" || + (window.__gradio_mode__ !== "app" && enable !== true) + ) { return; } @@ -39,6 +45,7 @@