From 2684a74db21922c5b3daf15799d31369fbbc1642 Mon Sep 17 00:00:00 2001 From: Red J Adaya Date: Thu, 15 Aug 2024 05:39:18 +0800 Subject: [PATCH] webview url fix (#219) Fixes issue where deleting the entire URL doesn't work in webview. --- frontend/app/view/webview/webview.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/app/view/webview/webview.tsx b/frontend/app/view/webview/webview.tsx index 60377b398..5ceae1ac3 100644 --- a/frontend/app/view/webview/webview.tsx +++ b/frontend/app/view/webview/webview.tsx @@ -18,6 +18,7 @@ export class WebViewModel implements ViewModel { viewName: jotai.Atom; viewText: jotai.Atom; url: jotai.PrimitiveAtom; + isUrlDirty: jotai.PrimitiveAtom; urlInput: jotai.PrimitiveAtom; urlInputFocused: jotai.PrimitiveAtom; isLoading: jotai.PrimitiveAtom; @@ -34,6 +35,7 @@ export class WebViewModel implements ViewModel { this.blockAtom = WOS.getWaveObjectAtom(`block:${blockId}`); this.url = jotai.atom(""); + this.isUrlDirty = jotai.atom(false); this.urlInput = jotai.atom(""); this.urlWrapperClassName = jotai.atom(""); this.urlInputFocused = jotai.atom(false); @@ -56,8 +58,9 @@ export class WebViewModel implements ViewModel { if (url && this.historyStack.length === 0) { this.addToHistoryStack(url); } - const currUrl = get(this.url); - if (currUrl) { + const urlIsDirty = get(this.isUrlDirty); + if (urlIsDirty) { + const currUrl = get(this.url); url = currUrl; } return [ @@ -173,6 +176,7 @@ export class WebViewModel implements ViewModel { handleUrlChange(event: React.ChangeEvent) { globalStore.set(this.url, event.target.value); + globalStore.set(this.isUrlDirty, true); } handleKeyDown(event: React.KeyboardEvent) {