Skip to content

Commit

Permalink
fix: fix filter func (jaywcjlove#473)
Browse files Browse the repository at this point in the history
do not ignore several types of INPUT
  • Loading branch information
rockindolphin authored Feb 2, 2024
1 parent adc70eb commit 4fc526d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ function getAllKeyCodes() {
function filter(event) {
const target = event.target || event.srcElement;
const { tagName } = target;
let flag = true;
let flag = true,
isInput = tagName == 'INPUT' && !['checkbox', 'radio', 'range', 'button', 'file', 'reset', 'submit', 'color'].includes(target.type);
// ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>
if (
target.isContentEditable
|| ((tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly)
|| ((isInput || tagName === 'TEXTAREA' || tagName === 'SELECT') && !target.readOnly)
) {
flag = false;
}
Expand Down

0 comments on commit 4fc526d

Please sign in to comment.