优化 picker embed 模式

This commit is contained in:
liaoxuezhi 2019-07-02 16:16:10 +08:00
parent b75f7b76ab
commit 7de4e9e501
4 changed files with 23 additions and 14 deletions

View File

@ -60,11 +60,13 @@ export class Card extends React.Component<CardProps> {
handleClick(e: React.MouseEvent<HTMLDivElement>) {
const target: HTMLElement = e.target as HTMLElement;
const ns = this.props.classPrefix;
let formItem;
if (
!e.currentTarget.contains(target) ||
~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
target.closest(`button, a, .${ns}Form-item`)
!e.currentTarget.contains(target)
|| ~['INPUT', 'TEXTAREA'].indexOf(target.tagName)
|| (formItem = target.closest(`button, a, .${ns}Form-item`))
&& e.currentTarget.contains(formItem)
) {
return;
}

View File

@ -613,11 +613,13 @@ export default class Form extends React.Component<FormProps, object> {
handleDialogConfirm(values: object[], action:Action, ctx:any, targets:Array<any>) {
const {
store
store,
onChange,
} = this.props;
if (action.mergeData && values.length === 1 && values[0] && targets[0].props.type === 'form') {
if ((action.mergeData || store.action.mergeData) && values.length === 1 && values[0] && targets[0].props.type === 'form') {
store.updateData(values[0]);
onChange && onChange(store.data, difference(store.data, store.pristine));
}
store.closeDialog(true);
@ -632,11 +634,13 @@ export default class Form extends React.Component<FormProps, object> {
handleDrawerConfirm(values: object[], action:Action, ctx:any, targets:Array<any>) {
const {
store
store,
onChange
} = this.props;
if (action.mergeData && values.length === 1 && values[0] && targets[0].props.type === 'form') {
if ((action.mergeData || store.action.mergeData) && values.length === 1 && values[0] && targets[0].props.type === 'form') {
store.updateData(values[0]);
onChange && onChange(store.data, difference(store.data, store.pristine));
}
store.closeDrawer(true);

View File

@ -721,11 +721,13 @@ export class ListItem extends React.Component<ListItemProps> {
handleClick(e: React.MouseEvent<HTMLDivElement>) {
const target: HTMLElement = e.target as HTMLElement;
const ns = this.props.classPrefix;
let formItem;
if (
!e.currentTarget.contains(target) ||
~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
target.closest(`button, a, .${ns}Form-item`)
!e.currentTarget.contains(target)
|| ~['INPUT', 'TEXTAREA'].indexOf(target.tagName)
|| (formItem = target.closest(`button, a, .${ns}Form-item`))
&& e.currentTarget.contains(formItem)
) {
return;
}

View File

@ -1455,12 +1455,13 @@ class TableRow extends React.Component<TableRowProps> {
handleClick(e: React.MouseEvent<HTMLTableRowElement>) {
const target: HTMLElement = e.target as HTMLElement;
const ns = this.props.classPrefix;
let formItem;
if (
!e.currentTarget.contains(target) ||
~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
// target.closest(`button, a, .${ns}Form-item`)
target.closest(`button, a`) // 兼容Picker的embed模式所以去掉了.${ns}Form-item
!e.currentTarget.contains(target)
|| ~['INPUT', 'TEXTAREA'].indexOf(target.tagName)
|| (formItem = target.closest(`button, a, .${ns}Form-item`))
&& e.currentTarget.contains(formItem)
) {
return;
}