Skip to content

Commit

Permalink
fix(popup): resolve scroll over throught (#2290)
Browse files Browse the repository at this point in the history
* fix(popup): resolve scroll over throught

* test: update snapshot

* fix(popup): prevent scroll throught
  • Loading branch information
LeeJim authored Aug 16, 2023
1 parent 277d8c7 commit e2a4c8f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/calendar/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ exports[`calendar :base 1`] = `
bind:transitionend="onTransitionEnd"
>
<wx-view
$gdc="{{[Function]}}"
$wxs:bind:touchmove="{{[Function]}}"
class="t-popup__content t-class-content"
data-prevention="{{true}}"
>
<wx-view
class="t-calendar t-calendar--popup class t-class"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ exports[`date-time-picker :base 1`] = `
bind:transitionend="onTransitionEnd"
>
<wx-view
$gdc="{{[Function]}}"
$wxs:bind:touchmove="{{[Function]}}"
class="t-popup__content t-class-content"
data-prevention="{{true}}"
>
<wx-view
class="t-picker t-class"
Expand Down
3 changes: 3 additions & 0 deletions src/dialog/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ exports[`dialog :base 1`] = `
bind:transitionend="onTransitionEnd"
>
<wx-view
$gdc="{{[Function]}}"
$wxs:bind:touchmove="{{[Function]}}"
class="t-popup__content t-class-content"
data-prevention="{{true}}"
>
<wx-view
class="t-dialog t-class"
Expand Down
3 changes: 3 additions & 0 deletions src/dropdown-menu/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ exports[`dropdown-menu :base 1`] = `
bind:transitionend="onTransitionEnd"
>
<wx-view
$gdc="{{[Function]}}"
$wxs:bind:touchmove="{{[Function]}}"
class="t-popup__content t-class-content"
data-prevention="{{true}}"
>
<wx-view
class="t-dropdown-item__body"
Expand Down
3 changes: 3 additions & 0 deletions src/picker/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ exports[`picker :base 1`] = `
bind:transitionend="onTransitionEnd"
>
<wx-view
$gdc="{{[Function]}}"
$wxs:bind:touchmove="{{[Function]}}"
class="t-popup__content t-class-content"
data-prevention="{{true}}"
>
<wx-view
class="t-picker t-class"
Expand Down
2 changes: 0 additions & 2 deletions src/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export default class Popup extends SuperComponent {
};

methods = {
onStopPropagation() {},

handleOverlayClick() {
const { closeOnOverlayClick } = this.properties;
if (closeOnOverlayClick) {
Expand Down
12 changes: 8 additions & 4 deletions src/popup/popup.wxml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<wxs src="./popup.wxs" module="utils" />
<wxs src="./popup.wxs" module="popup" />
<wxs src="../common/utils.wxs" module="_" />

<view
wx:if="{{realVisible}}"
style="{{_._style([utils.getPopupStyles(zIndex), style, customStyle])}}"
style="{{_._style([popup.getPopupStyles(zIndex), style, customStyle])}}"
class="{{_.cls(classPrefix, [placement])}} {{transitionClass}} class {{prefix}}-class"
bind:transitionend="onTransitionEnd"
>
<!-- 暂时移除:aria-role="dialog" aria-modal="{{ true }}",关联:https://github.com/Tencent/tdesign-miniprogram/issues/2142 -->
<view class="{{classPrefix}}__content {{prefix}}-class-content">
<view
data-prevention="{{preventScrollThrough || (overlayProps ? !!overlayProps.preventScrollThrough : false)}}"
bind:touchmove="{{popup.onContentTouchMove}}"
class="{{classPrefix}}__content {{prefix}}-class-content"
>
<slot name="content" />
<slot />
<view class="{{classPrefix}}__close" bind:tap="handleClose">
Expand All @@ -23,7 +27,7 @@
wx:if="{{showOverlay}}"
visible="{{visible}}"
z-index="{{overlayProps && overlayProps.zIndex || 11000}}"
prevent-scroll-through="{{preventScrollThrough || overlayProps && overlayProps.preventScrollThrough}}"
prevent-scroll-through="{{preventScrollThrough || (overlayProps ? !!overlayProps.preventScrollThrough : false)}}"
bind:tap="handleOverlayClick"
custom-style="{{overlayProps && overlayProps.style || ''}}"
/>
7 changes: 7 additions & 0 deletions src/popup/popup.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ function getPopupStyles(zIndex) {
return zIndexStyle;
}

function onContentTouchMove (e) {
if (e.target.dataset.prevention) {
return false;
};
}

module.exports = {
getPopupStyles: getPopupStyles,
onContentTouchMove: onContentTouchMove
};

0 comments on commit e2a4c8f

Please sign in to comment.