Skip to content

Commit

Permalink
[SDL] Fix the bug that prevents any text on the site from being deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
uysalibov committed Nov 7, 2024
1 parent 1ca9511 commit e5e78ce
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,13 @@ var LibrarySDL = {
// won't fire. However, it's fine (and in some cases necessary) to
// preventDefault for keys that don't generate a character. Otherwise,
// preventDefault is the right thing to do in general.
if (event.type !== 'keydown' || (!SDL.unicode && !SDL.textInput) || (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */)) {
event.preventDefault();
// Prevent default backspace and tab behavior when the target
// is not an input or textarea. Otherwise, no text in the site can be deleted.
if (event.type !== 'keydown' ||
(!SDL.unicode && !SDL.textInput) ||
((event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */ ) &&
event.target.tagName !== "INPUT" && event.target.tagName !== "TEXTAREA")) {
event.preventDefault();
}

if (event.type == 'mousedown') {
Expand Down

0 comments on commit e5e78ce

Please sign in to comment.