Skip to content

Commit

Permalink
Merge pull request #895 from Jackyzm/master
Browse files Browse the repository at this point in the history
解决多个Message重叠的bug、checkbox文档错误
  • Loading branch information
hazel54 committed Dec 13, 2018
2 parents 0c86908 + fa38e5b commit b2a335d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
3 changes: 2 additions & 1 deletion site/docs/en-US/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ constructor(props) {
}
render() {
return (
<Checkbox.Group options={this.state.checkList}>
<Checkbox.Group value={this.state.checkList}>
<Checkbox label="Option A"></Checkbox>
<Checkbox label="Option B"></Checkbox>
<Checkbox label="Option C"></Checkbox>
Expand Down Expand Up @@ -250,6 +250,7 @@ render() {
### Checkbox-group Attributes
| Attribute | Description | Type | Options | Default|
|---------- |-------- |---------- |------------- |-------- |
| value | Used for setting the currently selected value | string[] | - | [] |
|size | the size of checkbox buttons | string | large/small | —
|fill | border and background color when button is active | string || #20a0ff |
|textColor | font color when button is active | string || #ffffff |
Expand Down
1 change: 1 addition & 0 deletions site/docs/en-US/message-box.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The corresponding methods are: `MessageBox`, `MessageBox.alert`, `MessageBox.con
| Attribute | Description | Type | Accepted Values | Default |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| title | title of the MessageBox | string |||
| customClass | The class name of the container of the modal dialog | string || - |
| message | content of the MessageBox | string/ReactElement |||
| type | message type, used for icon display | string | success/info/warning/error ||
| customClass | custom class name for MessageBox | string |||
Expand Down
1 change: 1 addition & 0 deletions site/docs/zh-CN/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ render() {
### Checkbox.Group Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| value | 指定选中的选项 | string[] | - | [] |
| size | Checkbox 按钮组尺寸 | string | large, small ||
| fill | 按钮激活时的填充色和边框色 | string || #20a0ff |
| textColor | 按钮激活时的文本颜色 | string || #ffffff |
Expand Down
1 change: 1 addition & 0 deletions site/docs/zh-CN/message-box.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import { MessageBox } from 'element-react';
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| title | MessageBox 标题 | string |||
| customClass | 对话框外层容器的类名 | string || - |
| message | MessageBox 消息正文内容 | string/ReactElement |||
| type | 消息类型,用于显示图标 | string | success/info/<br>warning/error ||
| lockScroll | 是否在 MessageBox 出现时将 body 滚动锁定 | boolean || true |
Expand Down
22 changes: 12 additions & 10 deletions src/cascader/Cascader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Cascader extends Component {
});

before.then(() => {
this.handleInputChange(value);
});
this.handleInputChange(value);
});
} else {
this.handleInputChange(value);
}
Expand Down Expand Up @@ -325,7 +325,7 @@ class Cascader extends Component {
readOnly={!filterable}
placeholder={currentLabels.length ? undefined : this.placeholder()}
value={inputValue}
onChange={value => { this.setState({inputValue: value}) }}
onChange={value => { this.setState({ inputValue: value }) }}
onKeyUp={this.debouncedInputChange.bind(this)}
size={size}
disabled={disabled}
Expand All @@ -337,11 +337,11 @@ class Cascader extends Component {
/>
) : (
<i
className={this.classNames('el-input__icon el-icon-caret-bottom', {
'is-reverse': menuVisible
})}
/>
)
className={this.classNames('el-input__icon el-icon-caret-bottom', {
'is-reverse': menuVisible
})}
/>
)
}
/>
<View show={currentLabels.length}>
Expand Down Expand Up @@ -370,7 +370,9 @@ Cascader.childContextTypes = {
};

Cascader.propTypes = {
options: PropTypes.array.isRequired,
options: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.string
})).isRequired,
props: PropTypes.object,
value: PropTypes.array,
placeholder: PropTypes.string,
Expand Down Expand Up @@ -400,7 +402,7 @@ Cascader.defaultProps = {
value: 'value',
disabled: 'disabled'
},
beforeFilter: () => (() => {})
beforeFilter: () => (() => { })
}

export default ClickOutside(Cascader);
2 changes: 1 addition & 1 deletion src/message-box/MessageBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class MessageBox extends Component {
}

typeClass(): string {
return this.props.type && typeMap[this.props.type] && `el-icon-${ typeMap[this.props.type] }`;
return this.props.type && typeMap[this.props.type] && `el-icon-${typeMap[this.props.type]}`;
}

validate(value: string): boolean {
Expand Down
15 changes: 12 additions & 3 deletions src/message/Message.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ import Toast from './Toast';

export default function Message(props = {}, type) {
const div = document.createElement('div');

document.body.appendChild(div);
const messageBox = document.getElementsByClassName('el-message-content')[0];
if (messageBox) {
messageBox.appendChild(div);
document.body.appendChild(messageBox);
} else {
const messageBox = document.createElement('div');
messageBox.className = "el-message-content";
messageBox.appendChild(div);
document.body.appendChild(messageBox);
}

if (typeof props === 'string' || React.isValidElement(props)) {
props = {
Expand All @@ -20,8 +28,9 @@ export default function Message(props = {}, type) {

const component = React.createElement(Toast, Object.assign(props, {
willUnmount: () => {
const messageBox = document.getElementsByClassName('el-message-content')[0];
ReactDOM.unmountComponentAtNode(div);
document.body.removeChild(div);
messageBox.removeChild(div);

if (props.onClose instanceof Function) {
props.onClose();
Expand Down

0 comments on commit b2a335d

Please sign in to comment.