Fix not being able to search for the letter 'f'
This commit is contained in:
@@ -260,6 +260,8 @@ export const fs_node_type = (node: FSNode) => {
|
|||||||
return "pdf"
|
return "pdf"
|
||||||
} else if (
|
} else if (
|
||||||
node.file_type === "application/json" ||
|
node.file_type === "application/json" ||
|
||||||
|
node.file_type === "application/x-yaml" ||
|
||||||
|
node.file_type === "application/x-shellscript" ||
|
||||||
node.file_type.startsWith("text")
|
node.file_type.startsWith("text")
|
||||||
) {
|
) {
|
||||||
return "text"
|
return "text"
|
||||||
|
@@ -89,14 +89,15 @@ const clear_search = (blur) => {
|
|||||||
|
|
||||||
// Cursor navigation events can only be prevented with keydown. But we want to
|
// Cursor navigation events can only be prevented with keydown. But we want to
|
||||||
// use keyup for searching, so we use two listeners here
|
// 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") {
|
if (e.key === "Escape" || e.key === "ArrowUp" || e.key === "ArrowDown") {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const keyup = e => {
|
const input_keyup = e => {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
clear_search(true)
|
clear_search(true)
|
||||||
|
e.preventDefault()
|
||||||
} else if (e.key === "ArrowUp") {
|
} else if (e.key === "ArrowUp") {
|
||||||
if (selected_result > 0) {
|
if (selected_result > 0) {
|
||||||
selected_result--
|
selected_result--
|
||||||
@@ -123,6 +124,12 @@ const open_result = index => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const window_keydown = (e) => {
|
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 !== "") {
|
if (e.key === "Escape" && search_term !== "") {
|
||||||
clear_search(true)
|
clear_search(true)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -160,12 +167,16 @@ const window_keydown = (e) => {
|
|||||||
placeholder="Type to search in {$nav.base.name}"
|
placeholder="Type to search in {$nav.base.name}"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
bind:value={search_term}
|
bind:value={search_term}
|
||||||
on:keydown={keydown}
|
on:keydown={input_keydown}
|
||||||
on:keyup={keyup}
|
on:keyup={input_keyup}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="results">
|
<div class="results">
|
||||||
|
{#if search_term !== "" && search_results.length === 0}
|
||||||
|
No results found
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#each search_results as result, index}
|
{#each search_results as result, index}
|
||||||
<a
|
<a
|
||||||
href={"/d"+fs_encode_path(result)}
|
href={"/d"+fs_encode_path(result)}
|
||||||
@@ -256,7 +267,6 @@ const window_keydown = (e) => {
|
|||||||
.node_name {
|
.node_name {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
|
||||||
line-height: 1.2em;
|
line-height: 1.2em;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
@@ -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 {
|
if apiErr, ok := err.(pixelapi.Error); ok && apiErr.Status == http.StatusNotFound {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
wc.templates.Run(w, r, "list_not_found", templateData)
|
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 {
|
} else {
|
||||||
log.Error("API request error occurred: %s", err)
|
log.Error("API request error occurred: %s", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
Reference in New Issue
Block a user