From ad3ac339cf39f51a544f98e85546bca9263f7e39 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Sun, 26 Jul 2020 11:11:46 +0200 Subject: [PATCH] Fix clearing search result when closing search box --- src/JSONEditor.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/JSONEditor.svelte b/src/JSONEditor.svelte index 62334bc..6197cdd 100644 --- a/src/JSONEditor.svelte +++ b/src/JSONEditor.svelte @@ -261,6 +261,12 @@ focusActiveSearchResult(searchResult && searchResult.activeItem) } + function clearSearchResult () { + showSearch = false + searchText = '' + searchResult = search(doc, searchText, searchResult) + } + function previousSearchResult () { searchResult = searchPrevious(searchResult) focusActiveSearchResult(searchResult && searchResult.activeItem) @@ -517,10 +523,7 @@ onChange={changeSearchText} onNext={nextSearchResult} onPrevious={previousSearchResult} - onClose={() => { - showSearch = false - searchText = '' - }} + onClose={clearSearchResult} /> {/if}