Fix not being able to search for the letter 'f'

This commit is contained in:
2024-11-14 17:56:01 +01:00
parent 9a4d9a5d9b
commit e293c875b5
3 changed files with 20 additions and 5 deletions

View File

@@ -260,6 +260,8 @@ export const fs_node_type = (node: FSNode) => {
return "pdf"
} else if (
node.file_type === "application/json" ||
node.file_type === "application/x-yaml" ||
node.file_type === "application/x-shellscript" ||
node.file_type.startsWith("text")
) {
return "text"

View File

@@ -89,14 +89,15 @@ const clear_search = (blur) => {
// Cursor navigation events can only be prevented with keydown. But we want to
// use keyup for searching, so we use two listeners here
const keydown = e => {
const input_keydown = e => {
if (e.key === "Escape" || e.key === "ArrowUp" || e.key === "ArrowDown") {
e.preventDefault()
}
}
const keyup = e => {
const input_keyup = e => {
if (e.key === "Escape") {
clear_search(true)
e.preventDefault()
} else if (e.key === "ArrowUp") {
if (selected_result > 0) {
selected_result--
@@ -123,6 +124,12 @@ const open_result = index => {
}
const window_keydown = (e) => {
if (e.ctrlKey || e.altKey || e.metaKey) {
return // prevent custom shortcuts from interfering with system shortcuts
} else if (document.activeElement.type && document.activeElement.type === "text") {
return // Prevent shortcuts from interfering with input fields
}
if (e.key === "Escape" && search_term !== "") {
clear_search(true)
e.preventDefault()
@@ -160,12 +167,16 @@ const window_keydown = (e) => {
placeholder="Type to search in {$nav.base.name}"
style="width: 100%;"
bind:value={search_term}
on:keydown={keydown}
on:keyup={keyup}
on:keydown={input_keydown}
on:keyup={input_keyup}
/>
</form>
<div class="results">
{#if search_term !== "" && search_results.length === 0}
No results found
{/if}
{#each search_results as result, index}
<a
href={"/d"+fs_encode_path(result)}
@@ -256,7 +267,6 @@ const window_keydown = (e) => {
.node_name {
flex: 1 1 auto;
width: 100%;
overflow: hidden;
line-height: 1.2em;
word-break: break-all;
}

View File

@@ -154,6 +154,9 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
if apiErr, ok := err.(pixelapi.Error); ok && apiErr.Status == http.StatusNotFound {
w.WriteHeader(http.StatusNotFound)
wc.templates.Run(w, r, "list_not_found", templateData)
} else if strings.HasSuffix(err.Error(), "invalid control character in URL") {
w.WriteHeader(http.StatusNotFound)
wc.templates.Run(w, r, "list_not_found", templateData)
} else {
log.Error("API request error occurred: %s", err)
w.WriteHeader(http.StatusInternalServerError)