Skip to content

Commit

Permalink
fix(Balloon): strengthen robustness for align, close#517
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Apr 1, 2019
1 parent e11f1df commit a820b1a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/balloon/balloon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ import { normalMap, edgeMap } from './alignMap';
const { noop } = func;
const { Popup } = Overlay;

const alignList = [
't',
'r',
'b',
'l',
'tl',
'tr',
'bl',
'br',
'lt',
'lb',
'rt',
'rb',
];

let alignMap = normalMap;

/** Balloon */
Expand Down Expand Up @@ -61,20 +76,7 @@ export default class Balloon extends React.Component {
* 弹出层位置
* @enumdesc 上, 右, 下, 左, 上左, 上右, 下左, 下右, 左上, 左下, 右上, 右下 及其 两两组合
*/
align: PropTypes.oneOf([
't',
'r',
'b',
'l',
'tl',
'tr',
'bl',
'br',
'lt',
'lb',
'rt',
'rb',
]),
align: PropTypes.oneOf(alignList),
/**
* 弹层相对于trigger的定位的微调
*/
Expand Down Expand Up @@ -188,7 +190,7 @@ export default class Balloon extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
align: props.align,
align: alignList.includes(props.align) ? props.align : 'b',
visible: 'visible' in props ? props.visible : props.defaultVisible,
};
this._onClose = this._onClose.bind(this);
Expand All @@ -205,7 +207,7 @@ export default class Balloon extends React.Component {
});
}

if ('align' in nextProps) {
if ('align' in nextProps && alignList.includes(nextProps.align)) {
this.setState({
align: nextProps.align,
});
Expand Down

0 comments on commit a820b1a

Please sign in to comment.