Merge remote-tracking branch 'origin/master' into feature

This commit is contained in:
zombiej 2018-11-14 20:46:10 +08:00
commit 24a548a1ae
5 changed files with 19 additions and 3 deletions

View File

@ -87,7 +87,7 @@ If the form has been decorated by `Form.create` then it has `this.props.form` pr
| setFields | Set the value and error of a field. [Code Sample](https://github.com/react-component/form/blob/3b9959b57ab30b41d8890ff30c79a7e7c383cad3/examples/server-validate.js#L74-L79) | Function({ [fieldName]: { value: any, errors: [Error] } }) |
| setFields | Set value and error state of fields | ({<br />&nbsp;&nbsp;\[fieldName\]: {value: any, errors: \[Error\] }<br />}) => void |
| setFieldsValue | Set the value of a field. (Note: please don't use it in `componentWillReceiveProps`, otherwise, it will cause an endless loop, [reason](https://github.com/ant-design/ant-design/issues/2985)) | ({ \[fieldName\]&#x3A; value }) => void |
| validateFields | Validate the specified fields and get theirs values and errors. If you don't specify the parameter of fieldNames, you will vaildate all fields. | (<br />&nbsp;&nbsp;\[fieldNames: string\[]],<br />&nbsp;&nbsp;\[options: object\],<br />&nbsp;&nbsp;callback(errors, values)<br />) => void |
| validateFields | Validate the specified fields and get theirs values and errors. If you don't specify the parameter of fieldNames, you will validate all fields. | (<br />&nbsp;&nbsp;\[fieldNames: string\[]],<br />&nbsp;&nbsp;\[options: object\],<br />&nbsp;&nbsp;callback(errors, values)<br />) => void |
| validateFieldsAndScroll | This function is similar to `validateFields`, but after validation, if the target field is not in visible area of form, form will be automatically scrolled to the target field area. | same as `validateFields` |
### validateFields/validateFieldsAndScroll
@ -170,7 +170,7 @@ After wrapped by `getFieldDecorator`, `value`(or other property defined by `valu
| id | The unique identifier is required. support [nested fields format](https://github.com/react-component/form/pull/48). | string | |
| options.getValueFromEvent | Specify how to get value from event or other onChange arguments | function(..args) | [reference](https://github.com/react-component/form#option-object) |
| options.getValueProps | Get the component props according to field value. | function(value): any | [reference](https://github.com/react-component/form#option-object)
| options.initialValue | You can specify initial value, type, optional value of children node. (Note: Because `Form` will test equality with `===` internaly, we recommend to use vairable as `initialValue`, instead of literal) | | n/a |
| options.initialValue | You can specify initial value, type, optional value of children node. (Note: Because `Form` will test equality with `===` internally, we recommend to use variable as `initialValue`, instead of literal) | | n/a |
| options.normalize | Normalize value to form component, [a select-all example](https://codepen.io/afc163/pen/JJVXzG?editors=001) | function(value, prevValue, allValues): any | - |
| options.rules | Includes validation rules. Please refer to "Validation Rules" part for details. | object\[] | n/a |
| options.trigger | When to collect the value of children node | string | 'onChange' |

View File

@ -80,7 +80,9 @@ describe('Mention', () => {
if (process.env.REACT === '15') {
return;
}
wrapper.find('.ant-mention-dropdown-item').at(0).simulate('mouseDown');
wrapper.find('.ant-mention-dropdown-item').at(0).simulate('mouseUp');
wrapper.find('.ant-mention-dropdown-item').at(0).simulate('click');
jest.runAllTimers();
expect(onSelect).toBeCalled();
expect(wrapper.find('.public-DraftStyleDefault-block').text()).toBe('@afc163 ');

View File

@ -52,6 +52,7 @@ export interface MenuProps {
subMenuOpenDelay?: number;
getPopupContainer?: (triggerNode: Element) => HTMLElement;
focusable?: boolean;
onMouseEnter?: (e: MouseEvent) => void;
}
export interface MenuState {
@ -138,6 +139,16 @@ export default class Menu extends React.Component<MenuProps, MenuState> {
this.setState({});
}
}
// Restore vertical mode when menu is collapsed responsively when mounted
// https://github.com/ant-design/ant-design/issues/13104
// TODO: not a perfect solution, looking a new way to avoid setting switchingModeFromInline in this situation
handleMouseEnter = (e: MouseEvent) => {
this.restoreModeVerticalFromInline();
const { onMouseEnter } = this.props;
if (onMouseEnter) {
onMouseEnter(e);
}
}
handleTransitionEnd = (e: TransitionEvent) => {
// when inlineCollapsed menu width animation finished
// https://github.com/ant-design/ant-design/issues/12864
@ -252,6 +263,7 @@ export default class Menu extends React.Component<MenuProps, MenuState> {
{...this.props}
{...menuProps}
onTransitionEnd={this.handleTransitionEnd}
onMouseEnter={this.handleMouseEnter}
/>
);
}

View File

@ -321,7 +321,7 @@
@menu-inline-toplevel-item-height: 40px;
@menu-item-height: 40px;
@menu-collapsed-width: 80px;
@menu-bg: transparent;
@menu-bg: @component-background;
@menu-popup-bg: @component-background;
@menu-item-color: @text-color;
@menu-highlight-color: @primary-color;

View File

@ -138,6 +138,7 @@ class Tooltip extends React.Component<TooltipProps, any> {
display: 'inline-block', // default inline-block is important
...picked,
cursor: 'not-allowed',
width: element.props.block ? '100%' : null,
};
const buttonStyle = {
...omitted,
@ -210,6 +211,7 @@ class Tooltip extends React.Component<TooltipProps, any> {
const child = this.getDisabledCompatibleChildren(
React.isValidElement(children) ? children : <span>{children}</span>,
);
const childProps = child.props;
const childCls = classNames(childProps.className, {
[openClassName || `${prefixCls}-open`]: true,