Skip to content

Commit

Permalink
fix: picker closing the mask flicker (#1263)
Browse files Browse the repository at this point in the history
* fix: picker closing the mask flicker

* fix: picker closing the mask flicker

* chore: 本地文档站点研发

* feat: 实验性组件深色模式适配
  • Loading branch information
rayhomie authored Aug 12, 2024
1 parent e9ac3ea commit 6027a60
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 28 deletions.
2 changes: 1 addition & 1 deletion compiled/alipay/demo/pages/PageContainer/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultTitle": "PageContainer",
"defaultTitle": "",
"titleBarColor": "#ffffff",
"transparentTitle": "auto",
"usingComponents": {
Expand Down
4 changes: 3 additions & 1 deletion compiled/alipay/src/PageContainer/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

.@{prefix} {
overflow: auto;
color: @COLOR_TEXT_PRIMARY;

&-safe-top {
padding-top: constant(safe-area-inset-top);
Expand All @@ -22,7 +23,8 @@
top: 0;
width: 100%;
height: 100vh;
background: rgba(255, 255, 255, 0.4);
background: @COLOR_BACKGROUND;
opacity: 0.4;
z-index: 3;
}

Expand Down
29 changes: 19 additions & 10 deletions compiled/alipay/src/Popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,32 @@ Component(
},
undefined,
{
async deriveDataFromProps(nextProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
'duration',
'animation',
]);
const enableAnimation = animation && duration > 0;

if (
nextProps.visible !== visible &&
enableAnimation &&
!nextProps.visible &&
!this.data.closing
) {
this.setData({ closing: true });
}
},
didUpdate(prevProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
'duration',
'animation',
]);
const enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible) {
if (enableAnimation && !visible) {
setTimeout(() => {
// 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
this.setData({ closing: true });
});
}
if (!enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
if (prevProps.visible !== visible && !enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
},
}
Expand Down
1 change: 1 addition & 0 deletions compiled/alipay/src/Typography/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
display: flex;
align-items: center;
width: fit-content;
color: @COLOR_TEXT_PRIMARY;
.@{tabsPrefix} {
&-text {
line-height: @default-line-height;
Expand Down
2 changes: 1 addition & 1 deletion compiled/wechat/src/Popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Component(PopupDefaultProps, {
'visible': function (nextProps) {
var visible = nextProps.visible, duration = nextProps.duration, animation = nextProps.animation;
var enableAnimation = animation && duration > 0;
if (enableAnimation && !visible) {
if (enableAnimation && !visible && !this.data.closing) {
this.setData({ closing: true });
}
if (!enableAnimation) {
Expand Down
4 changes: 2 additions & 2 deletions demo/pages/PageContainer/index.json5
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
/// #if WECHAT
"navigationBarTitleText": "PageContainer",
"navigationBarTitleText": "",
/// #endif

/// #if ALIPAY
"defaultTitle": "PageContainer",
"defaultTitle": "",
/// #endif

"titleBarColor": "#ffffff",
Expand Down
5 changes: 4 additions & 1 deletion scripts/dev-doc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { fork } = require('child_process');
const { fork,execFile } = require('child_process');
const { minidev } = require('minidev');

(async () => {
execFile('tsx', [`${process.cwd()}/scripts/dev.ts`]);

const path = require('path');

const { devServer } = await minidev.dev({
Expand All @@ -22,6 +24,7 @@ const { minidev } = require('minidev');
SERVER: devServer.server,
},
});

});

devServer.on('error', (err) => {
Expand Down
4 changes: 3 additions & 1 deletion src/PageContainer/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

.@{prefix} {
overflow: auto;
color: @COLOR_TEXT_PRIMARY;

&-safe-top {
padding-top: constant(safe-area-inset-top);
Expand All @@ -22,7 +23,8 @@
top: 0;
width: 100%;
height: 100vh;
background: rgba(255, 255, 255, 0.4);
background: @COLOR_BACKGROUND;
opacity: 0.4;
z-index: 3;
}

Expand Down
31 changes: 20 additions & 11 deletions src/Popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,32 @@ Component(
undefined,
{
/// #if ALIPAY
async deriveDataFromProps(nextProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
'duration',
'animation',
]);
const enableAnimation = animation && duration > 0;

if (
nextProps.visible !== visible &&
enableAnimation &&
!nextProps.visible &&
!this.data.closing
) {
this.setData({ closing: true });
}
},
didUpdate(prevProps) {
const [visible, duration, animation] = getValueFromProps(this, [
'visible',
'duration',
'animation',
]);
const enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible) {
if (enableAnimation && !visible) {
setTimeout(() => {
// 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
this.setData({ closing: true });
});
}
if (!enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
if (prevProps.visible !== visible && !enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
}
},
/// #endif
Expand All @@ -66,7 +75,7 @@ Component(
'visible': function (nextProps) {
const { visible, duration, animation } = nextProps;
const enableAnimation = animation && duration > 0;
if (enableAnimation && !visible) {
if (enableAnimation && !visible && !this.data.closing) {
this.setData({ closing: true });
}
if (!enableAnimation) {
Expand Down
1 change: 1 addition & 0 deletions src/Typography/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
display: flex;
align-items: center;
width: fit-content;
color: @COLOR_TEXT_PRIMARY;
.@{tabsPrefix} {
&-text {
line-height: @default-line-height;
Expand Down
1 change: 1 addition & 0 deletions tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import esbuild from 'esbuild';
import fs from 'fs';
// @ts-ignore
import { createInstrumenter } from 'istanbul-lib-instrument';
import os from 'os';
import path from 'path';
Expand Down

0 comments on commit 6027a60

Please sign in to comment.