Skip to content

Commit

Permalink
Merge branch 'autocomplete' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmz committed Jun 29, 2024
2 parents 202e0f4 + 5defec1 commit 3e8ee4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/autocomplete/autocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Selector } from './selector';

// There should be no alphanumeric characters right before the "@" (to exclude
// email-like strings)
const defaultAnchor = /(?<![a-z\d])@/gi;
const defaultAnchor = /(^|[^a-z\d])@/gi;

export function Autocomplete({ inputRef, context, anchor = defaultAnchor }) {
const [query, setQuery] = useState(/** @type {string|null}*/ null);
Expand Down Expand Up @@ -43,9 +43,9 @@ export function Autocomplete({ inputRef, context, anchor = defaultAnchor }) {

// Clears the query after 100ms of no focus. This delay allows to click on
// the selector by mouse.
const timer = 0;
let timer = 0;
const focusHandler = () => clearTimeout(timer);
const blurHandler = () => setTimeout(() => setQuery(null), 100);
const blurHandler = () => (timer = setTimeout(() => setQuery(null), 500));

input.addEventListener('blur', blurHandler);
input.addEventListener('focus', focusHandler);
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import styles from './layout-header.module.scss';
import { SignInLink } from './sign-in-link';
import { Autocomplete } from './autocomplete/autocomplete';

const autocompleteAnchor = /(?<![a-z\d])@|((from|to|author|by|in|commented-?by|liked-?by):)/gi;
const autocompleteAnchor = /(^|[^a-z\d])@|((from|to|author|by|in|commented-?by|liked-?by):)/gi;

export const LayoutHeader = withRouter(function LayoutHeader({ router }) {
const dispatch = useDispatch();
Expand Down

0 comments on commit 3e8ee4c

Please sign in to comment.