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

KeyboardManager#hasFocus misses valid contenteditable attributes #6509

Closed
mattexdee opened this issue Jan 11, 2022 · 0 comments
Closed

KeyboardManager#hasFocus misses valid contenteditable attributes #6509

mattexdee opened this issue Jan 11, 2022 · 0 comments
Assignees
Labels
api Issues related to the API used by Mod Devs bug Functionality which is not working as intended

Comments

@mattexdee
Copy link
Contributor

Originally in GitLab by @mattexdee

Originally posted by stwlam (he/him): https://discord.com/channels/170995199584108546/872553750877835264/929081310205595689

  • ALL MODULES DISABLED? no
  • OS, Hosting, Browser (if applicable): Debian 11, Electron Application
  • Short Description of bug: KeyboardManager#hasFocus misses valid contenteditable attributes
  • Simple steps to reproduce the bug: Add a tag of or to any UI (equivalent to contenteditable="true" according to https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable)
  • Screenshots and/or console errors:
  • The following will incorrectly return false since neither of the above have an attribute value of the string "true":
   /**
   * Test whether a Form Element currently has focus
   * @return {boolean}
   */
  get hasFocus() {
    // Pulled from https://www.w3schools.com/html/html_form_elements.asp
    const formElements = [ "input", "select", "textarea", "option", "[contentEditable=true]"];
    const selector = formElements.map(el => `${el}:focus`).join(", ");
    return document.querySelectorAll(selector).length > 0;
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API used by Mod Devs bug Functionality which is not working as intended
Projects
No open projects
Status: No status
Development

No branches or pull requests

2 participants