Replace event dispatcher with a callback in filemanager
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { onMount } from "svelte";
|
||||
import { fs_search, fs_encode_path, fs_thumbnail_url } from "lib/FilesystemAPI";
|
||||
import { fs_search, fs_encode_path, fs_thumbnail_url } from "lib/FilesystemAPI.svelte";
|
||||
import type { FSNavigator } from "filesystem/FSNavigator";
|
||||
import { loading_finish, loading_start } from "lib/Loading";
|
||||
|
||||
@@ -118,13 +116,17 @@ const input_keyup = (e: KeyboardEvent) => {
|
||||
}
|
||||
|
||||
// Submitting opens the selected result
|
||||
const submit_search = () => {
|
||||
const submit_search = (e: Event) => {
|
||||
e.preventDefault()
|
||||
if (search_results.length !== 0) {
|
||||
open_result(selected_result)
|
||||
}
|
||||
}
|
||||
|
||||
const open_result = (index: number) => {
|
||||
const open_result = (index: number, e?: MouseEvent) => {
|
||||
if (e !== undefined) {
|
||||
e.preventDefault()
|
||||
}
|
||||
nav.navigate(search_results[index], true)
|
||||
clear_search(false)
|
||||
}
|
||||
@@ -164,7 +166,7 @@ const window_keydown = (e: KeyboardEvent) => {
|
||||
{/if}
|
||||
|
||||
<div class="center">
|
||||
<form class="search_form" onsubmit={preventDefault(submit_search)}>
|
||||
<form class="search_form" onsubmit={submit_search}>
|
||||
<i class="icon">search</i>
|
||||
<input
|
||||
bind:this={search_bar}
|
||||
@@ -192,7 +194,7 @@ const window_keydown = (e: KeyboardEvent) => {
|
||||
{#each search_results as result, index}
|
||||
<a
|
||||
href={"/d"+fs_encode_path(result)}
|
||||
onclick={preventDefault(() => open_result(index))}
|
||||
onclick={(e) => open_result(index, e)}
|
||||
class="node"
|
||||
class:node_selected={selected_result === index}
|
||||
>
|
||||
|
Reference in New Issue
Block a user