diff --git a/src/components/link.jsx b/src/components/link.jsx index 8f076763..04793831 100644 --- a/src/components/link.jsx +++ b/src/components/link.jsx @@ -19,7 +19,8 @@ const Link = forwardRef((props, ref) => { let hash = (location.hash || '').replace(/^#/, '').trim(); if (hash === '') hash = '/'; const { to, ...restProps } = props; - const isActive = decodeURIComponent(hash) === to; + // TODO: maybe better pass hash into URL to deconstruct the pathname and search, then decodeURIComponent them + const isActive = hash === to || decodeURIComponent(hash) === to; return ( { if (focusItem) { e.preventDefault(); focusItem.click(); - props?.onSubmit?.(e); } setSearchMenuOpen(false); } @@ -221,7 +220,14 @@ const SearchForm = forwardRef((props, ref) => { return 0; }) .map(({ label, to, hidden, type }) => ( - + { + props?.onSubmit?.(e); + }} + > {!!q && (
- {!!type && ‹ All} + {!!type && ( + + ‹ All + + )} {[ { label: 'Accounts', type: 'accounts', - to: `/search?q=${q}&type=accounts`, + to: `/search?q=${encodeURIComponent(q)}&type=accounts`, }, { label: 'Hashtags', type: 'hashtags', - to: `/search?q=${q}&type=hashtags`, + to: `/search?q=${encodeURIComponent(q)}&type=hashtags`, }, { label: 'Posts', type: 'statuses', - to: `/search?q=${q}&type=statuses`, + to: `/search?q=${encodeURIComponent(q)}&type=statuses`, }, ] .sort((a, b) => {