ByzantineFailure / BPM-for-Discord

BPM for Discord's Desktop App. Includes one-click installers, update notifications, and custom script support.
GNU Affero General Public License v3.0
17 stars 8 forks source link

Emote search won't focus #99

Closed Tadaboody closed 6 years ago

Tadaboody commented 6 years ago

Bug

Typing in the emote search switches focus to chat

ByzantineFailure commented 6 years ago

Symptoms

Select search input after having chat input focused.

Type things into search.

Focus switches to chat input.

Some research

It looks like if I do this in the console, I can get functionality working:

  chatInput.blur();
  searchInput.focus();

However this doesn't seem to work if I do it in a click handler, or even consistently at all from the console.

ByzantineFailure commented 6 years ago
chatInput.addEventListener('keydown', (event) => {
  if (event.target !== chatInput) {
    return;
  }
 event.stopPropagation();
});

That should do the trick. I don't know what exactly changed in either react or discord to make react's global listener insist on hijacking focus, but whatever, I don't really care. Stopping propagation just short-circuits the entire issue in a neat and self-contained way.

Pushing this out as a fix