Skip to content

Commit 09224c9

Browse files
authored
fix: component can still be selected when disabled (#194)
* fix: component can still be selected when disabled * fix: interface import * update * update test
1 parent 333234e commit 09224c9

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

examples/case.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint no-console:0 */
22

33
import React from 'react';
4+
import { CSSMotionProps } from 'rc-motion';
45
import Trigger, { BuildInPlacements } from '../src';
56
import './case.less';
6-
import { MotionType } from '../src/interface';
77

88
const builtinPlacements: BuildInPlacements = {
99
left: {
@@ -32,11 +32,11 @@ const builtinPlacements: BuildInPlacements = {
3232
},
3333
};
3434

35-
const Motion: MotionType = {
35+
const Motion: CSSMotionProps = {
3636
motionName: 'case-motion',
3737
};
3838

39-
const MaskMotion: MotionType = {
39+
const MaskMotion: CSSMotionProps = {
4040
motionName: 'mask-motion',
4141
};
4242

@@ -98,7 +98,10 @@ const Demo = () => {
9898
const [placement, placementProps] = useControl('value', 'right');
9999
const [stretch, stretchProps] = useControl('value', '');
100100
const [motion, motionProps] = useControl('checked', true);
101-
const [destroyPopupOnHide, destroyPopupOnHideProps] = useControl('checked', false);
101+
const [destroyPopupOnHide, destroyPopupOnHideProps] = useControl(
102+
'checked',
103+
false,
104+
);
102105
const [mask, maskProps] = useControl('checked', false);
103106
const [maskClosable, maskClosableProps] = useControl('checked', true);
104107
const [forceRender, forceRenderProps] = useControl('checked', false);
@@ -215,7 +218,11 @@ const Demo = () => {
215218
}}
216219
>
217220
<div
218-
style={{ margin: 20, display: 'inline-block', background: 'rgba(255, 0, 0, 0.05)' }}
221+
style={{
222+
margin: 20,
223+
display: 'inline-block',
224+
background: 'rgba(255, 0, 0, 0.05)',
225+
}}
219226
tabIndex={0}
220227
role="button"
221228
>

src/Popup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class Popup extends Component<PopupProps, PopupState> {
304304
...this.getZIndexStyle(),
305305
...style,
306306
opacity: status === 'stable' || !visible ? undefined : 0,
307+
pointerEvents: status === 'stable' || !visible ? undefined : 'none',
307308
};
308309

309310
// ================= Motions =================

tests/util.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('Trigger.Util', () => {
8484
);
8585

8686
expect(wrapper.html()).toEqual(
87-
'<div>light</div><div><div class="rc-trigger-popup" style="opacity: 0;"><div>bamboo</div></div></div>',
87+
'<div>light</div><div><div class="rc-trigger-popup" style="opacity: 0; pointer-events: none;"><div>bamboo</div></div></div>',
8888
);
8989
});
9090
});

0 commit comments

Comments
 (0)