Skip to content

[Bug] Closing new tab with ctrl+w bugs out current selection #56

@the-overdriven

Description

@the-overdriven
  1. Open Bookmarks Commander and select any bookmark (need to have many bookmarks).
  2. Open new tab (any page).
  3. Press Ctrl+W.
  4. New tab closes and Bookmarks Commander is now active, but for some strange reason it changes the current selection to a random bookmark. It doesn't happen when the new tab is closed by clicking on the "x".

This is really odd, since Ctrl + KeyW doesn't seem to be assigned to any command in bookmarks-commander.

I've found the culprit. This keyup event listener in components\directory-view\list-view.js is causing it:

// to prevent conflict with command access
shadow.addEventListener('keyup', e => {
  if (e.code.startsWith('Key') || e.code.startsWith('Digit')) {
    const d = this.content.querySelector(`.entry[data-selected=true] ~ .entry[data-key="${e.key}"]`);
    if (d) {
      d.click();
    }
    else {
      const d = this.content.querySelector(`.entry[data-key="${e.key}"]`);
      if (d) {
        d.click();
      }
    }
  }
  else if (
    e.code === 'Backspace' &&
    e.shiftKey === false && e.altKey === false && e.metaKey === false && e.ctrlKey === false
  ) {
    const d = this.content.querySelector('.entry[data-index="-1"]');
    if (d) {
      this.dbclick(d);
    }
    else {
      engine.notify('beep');
    }
  }
});

After removing it, the bug is gone and everything still works. What was the "conflict with command access"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions