Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search function starts the search term with a space and the cursor is not centered #7

Closed
mehmetmalli opened this issue Apr 6, 2020 · 1 comment

Comments

@mehmetmalli
Copy link

mehmetmalli commented Apr 6, 2020

Since the search bar is made visible with the keydown event, it registers the space character.
This adds a whitespace before the actual search term and also causes the cursor to be not perfectly centered but off by 1.

Easy fix:
Change "keydown" to "keyup" in this code segment

document.addEventListener("keydown", event => {
    if (event.keyCode == 32) {          // Spacebar code to open search
        document.getElementById('search').style.display = 'flex';
        document.getElementById('search-field').focus();
    } else if (event.keyCode == 27) {   // Esc to close search
        document.getElementById('search-field').value = '';
        document.getElementById('search-field').blur();
        document.getElementById('search').style.display = 'none';
    }
});
Jaredk3nt added a commit that referenced this issue Jul 15, 2020
@Jaredk3nt
Copy link
Owner

Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants