Skip to content

Commit

Permalink
Merge pull request #577 from nilennoct/fix/trigger_select_click_events
Browse files Browse the repository at this point in the history
fix: trigger click event on `<select>` elements correctly
  • Loading branch information
Maizify committed Nov 2, 2022
2 parents ecc524b + fc8a4a9 commit 95864fa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/core.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
touchMove(e) {
const touch = e.changedTouches[0];
if (
Math.abs(touch.pageX - mockTapInfo.touchstartX) > mockTapInfo.tapBoundary ||
Math.abs(touch.pageX - mockTapInfo.touchstartX) > mockTapInfo.tapBoundary ||
Math.abs(touch.pageY - mockTapInfo.touchstartY) > mockTapInfo.tapBoundary
) {
mockTapInfo.touchHasMoved = true;
Expand All @@ -261,15 +261,18 @@
touchEnd(e) {
// move and time within limits, manually trigger `click` event
if (
mockTapInfo.touchHasMoved === false &&
e.timeStamp - mockTapInfo.lastTouchStartTime < mockTapInfo.tapTime &&
mockTapInfo.touchHasMoved === false &&
e.timeStamp - mockTapInfo.lastTouchStartTime < mockTapInfo.tapTime &&
mockTapInfo.targetElem != null
) {
const tagName = mockTapInfo.targetElem.tagName.toLowerCase();
let needFocus = false;
switch (tagName) {
case 'textarea': // focus
needFocus = true; break;
case 'select':
needFocus = !mockTapInfo.targetElem.disabled && !mockTapInfo.targetElem.readOnly;
break;
case 'input':
switch (mockTapInfo.targetElem.type) {
case 'button':
Expand Down

0 comments on commit 95864fa

Please sign in to comment.