diff --git a/svelte/src/filesystem/Filesystem.svelte b/svelte/src/filesystem/Filesystem.svelte index 5c89d0f..1882829 100644 --- a/svelte/src/filesystem/Filesystem.svelte +++ b/svelte/src/filesystem/Filesystem.svelte @@ -43,7 +43,9 @@ let state = { shuffle: false, } -onMount(() => fs_navigator.open_node(window.initial_node, false)) +onMount(() => { + fs_navigator.open_node(window.initial_node, false) +}) const keydown = e => { if (e.ctrlKey || e.altKey || e.metaKey) { @@ -115,10 +117,6 @@ const loading_evt = e => { bind:this={fs_navigator} bind:state on:loading={loading_evt} - on:navigation_complete={() => { - // Reset the view to the file view if we were in search view - view = "file" - }} />
@@ -155,6 +153,7 @@ const loading_evt = e => { state={state} fs_navigator={fs_navigator} on:loading={loading_evt} + on:done={() => {view = "file"}} /> {/if}
diff --git a/svelte/src/filesystem/Navigator.svelte b/svelte/src/filesystem/Navigator.svelte index bc83d75..ff44660 100644 --- a/svelte/src/filesystem/Navigator.svelte +++ b/svelte/src/filesystem/Navigator.svelte @@ -67,16 +67,11 @@ export const open_node = (node, push_history) => { // still replace the URL with replaceState. This way the user is not greeted // to a 404 page when refreshing after renaming a file window.document.title = node.path[node.base_index].name+" ~ pixeldrain" + let url = "/d/"+node.path[0].id+node.path[node.base_index].path if (push_history) { - window.history.pushState( - {}, window.document.title, - "/d/"+node.path[0].id+node.path[node.base_index].path, - ) + window.history.pushState({}, window.document.title, url) } else { - window.history.replaceState( - {}, window.document.title, - "/d/"+node.path[0].id+node.path[node.base_index].path, - ) + window.history.replaceState({}, window.document.title, url) } // If the new node is a child of the previous node we save the parent's diff --git a/svelte/src/filesystem/SearchView.svelte b/svelte/src/filesystem/SearchView.svelte index e5589fb..f12a1e2 100644 --- a/svelte/src/filesystem/SearchView.svelte +++ b/svelte/src/filesystem/SearchView.svelte @@ -59,15 +59,24 @@ const search = async (limit = 10) => { } } -// Submitting opens the first result -const submit_search = () => { - if (search_results.length !== 0) { - fs_navigator.navigate(search_results[0], true) +const keyup = e => { + if (e.key === "Escape") { + dispatch("done") + } else { + search() } } -const node_click = index => { +// Submitting opens the first result +const submit_search = () => { + if (search_results.length !== 0) { + open_result(0) + } +} + +const open_result = index => { fs_navigator.navigate(search_results[index], true) + dispatch("done") } @@ -84,12 +93,19 @@ const node_click = index => { {/if} - + +
@@ -99,7 +115,7 @@ const node_click = index => { {#each search_results as result, index} node_click(index)} + on:click|preventDefault={() => open_result(index)} class="node" > @@ -132,10 +148,14 @@ const node_click = index => { } .search_bar { + display: flex; + flex-direction: column; + margin-top: 10px; +} +.search_form { display: flex; flex-direction: row; align-items: center; - margin-top: 10px; } .term { flex: 1 1 auto;