Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Autofocus filter bars and don't insert "/" when activated via keyboard (#6099)

Adam Rutkowski40c1f8639b7f
diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex
index dcdd6cafd8..63c0e9917f 100644
--- a/lib/plausible_web/components/generic.ex
+++ b/lib/plausible_web/components/generic.ex
@@ -1192,7 +1192,8 @@ defmodule PlausibleWeb.Components.Generic do
x-ref="filter_text"
phx-debounce={200}
autocomoplete="off"
- x-on:keydown.slash.window="if (['INPUT', 'TEXTAREA', 'SELECT'].includes(document.activeElement.tagName) || document.activeElement.isContentEditable) return; $refs.filter_text.focus(); $refs.filter_text.select();"
+ autofocus
+ x-on:keydown.slash.window="if (['INPUT', 'TEXTAREA', 'SELECT'].includes(document.activeElement.tagName) || document.activeElement.isContentEditable) return; $event.preventDefault(); $refs.filter_text.focus(); $refs.filter_text.select();"
x-on:keydown.escape="$refs.filter_text.blur(); $refs.reset_filter?.dispatchEvent(new Event('click', {bubbles: true, cancelable: true}));"
value={@filter_text}
x-on:focus={"$refs.filter_text.placeholder = '#{@placeholder}';"}