Skip to content

Commit 665e18f

Browse files
authoredMar 22, 2022
fix(Popover): children 为 Icon 定位错误问题 (#702)
1 parent 372edfe commit 665e18f

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed
 

‎packages/react-popover/README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ class Demo extends React.Component {
2828
super();
2929
this.state = {
3030
isOpen: false,
31+
isOpen1: false,
3132
}
3233
}
33-
onClick() {
34-
this.setState({ isOpen: false });
34+
onClick(field) {
35+
this.setState({ [field]: false });
3536
}
36-
handleVisibleChange(isOpen) {
37-
this.setState({ isOpen });
37+
38+
handleVisibleChange(field, isOpen) {
39+
this.setState({ [field]:isOpen });
3840
}
3941
render() {
4042
return (
@@ -43,15 +45,15 @@ class Demo extends React.Component {
4345
trigger="click"
4446
placement="top"
4547
isOpen={this.state.isOpen}
46-
onVisibleChange={this.handleVisibleChange.bind(this)}
48+
onVisibleChange={this.handleVisibleChange.bind(this, 'isOpen')}
4749
content={
4850
<Card bordered={false} title="Card标题" extra={<a href="#">更多</a>} style={{ width: 200 }}>
4951
<div>Are you sure you want to delete these items? You won't be able to recover them.</div>
5052
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 15 }}>
51-
<Button size="small" onClick={this.onClick.bind(this)}>
53+
<Button size="small" onClick={this.onClick.bind(this, 'isOpen')}>
5254
Cancel
5355
</Button>
54-
<Button type="danger" size="small" onClick={this.onClick.bind(this)}>
56+
<Button type="danger" size="small" onClick={this.onClick.bind(this, 'isOpen')}>
5557
Delete
5658
</Button>
5759
</div>
@@ -64,14 +66,16 @@ class Demo extends React.Component {
6466
<Popover
6567
trigger="click"
6668
placement="top"
69+
isOpen={this.state.isOpen1}
70+
onVisibleChange={this.handleVisibleChange.bind(this, 'isOpen1')}
6771
content={
6872
<Card bordered={false} title="Card标题" extra={<a href="#">更多</a>} style={{ width: 200 }}>
6973
<div>Are you sure you want to delete these items? You won't be able to recover them.</div>
7074
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 15 }}>
71-
<Button size="small" onClick={this.onClick.bind(this)}>
75+
<Button size="small" onClick={this.onClick.bind(this, 'isOpen1')}>
7276
Cancel
7377
</Button>
74-
<Button type="danger" size="small" onClick={this.onClick.bind(this)}>
78+
<Button type="danger" size="small" onClick={this.onClick.bind(this, 'isOpen1')}>
7579
Delete
7680
</Button>
7781
</div>

‎packages/react-popover/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class Popover extends React.Component<PopoverProps> {
4848
{typeof this.props.children === 'object' && (this.props.children as JSX.Element).type.name !== 'Icon' ? (
4949
this.props.children
5050
) : (
51-
<span>{this.props.children}</span>
51+
<span style={{ display: 'block', writingMode: 'vertical-rl' }}>{this.props.children}</span>
5252
)}
5353
</OverlayTrigger>
5454
);

0 commit comments

Comments
 (0)
Please sign in to comment.