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

Implement fix: KeyboardHelper may damage site functionality #796

Open
fmiu-imperosoftware opened this issue Nov 15, 2023 · 0 comments
Open

Comments

@fmiu-imperosoftware
Copy link

The KeyboardHelper may brake site functionality because it add/remove document keyboard event listeners using event handlers properties. If the parent site has already some event listeners added in the same manner they are removed by this code and the site functionality is damaged.

  GrabKeyInput (): any {
    if (this.KeyInputGrab) { return }
    document.onkeyup = this.handleKeyUp.bind(this)
    document.onkeydown = this.handleKeyDown.bind(this)
    document.onkeypress = this.handleKeys.bind(this)
    this.KeyInputGrab = true
  }
  UnGrabKeyInput (): any {
    if (!this.KeyInputGrab) { return }
    document.onkeyup = null
    document.onkeydown = null
    document.onkeypress = null
    this.KeyInputGrab = false
  }

Using addEventListener/removeEventListener would be better, to preserve any previous event handlers.

constructor () 
    this.handleKeyUp = this.handleKeyUp.bind(this)

GrabKeyInput
    document.addEventListener('keyup', this.handleKeyUp)

UnGrabKeyInput 
    document.removeEventListener('keyup', this.handleKeyUp)
@graikhel-intel graikhel-intel moved this to Backlog in Sprint Planning Dec 29, 2023
@mechris1 mechris1 changed the title KeyboardHelper may damage site functionality SPIKE: KeyboardHelper may damage site functionality Jan 2, 2024
@mechris1 mechris1 moved this from Backlog to Todo in Sprint Planning Jan 30, 2024
@mechris1 mechris1 changed the title SPIKE: KeyboardHelper may damage site functionality Implement fix: KeyboardHelper may damage site functionality Jan 30, 2024
@mechris1 mechris1 moved this from Todo to Backlog in Sprint Planning Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants