修复 Picker 中 select 弹出位置问题

This commit is contained in:
2betop 2020-08-03 14:39:45 +08:00
parent c7d2add552
commit 09f576d779
2 changed files with 12 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import {SchemaNode, Schema, Action} from '../types';
import {filter} from '../utils/tpl'; import {filter} from '../utils/tpl';
import Modal from '../components/Modal'; import Modal from '../components/Modal';
import findLast from 'lodash/findLast'; import findLast from 'lodash/findLast';
import {guid, isVisible} from '../utils/helper'; import {guid, isVisible, autobind} from '../utils/helper';
import {reaction} from 'mobx'; import {reaction} from 'mobx';
import {Icon} from '../components/icons'; import {Icon} from '../components/icons';
import {ModalStore, IModalStore} from '../store/modal'; import {ModalStore, IModalStore} from '../store/modal';
@ -294,6 +294,13 @@ export default class Dialog extends React.Component<DialogProps, DialogState> {
}); });
} }
@autobind
getPopOverContainer() {
return (findDOMNode(this) as HTMLElement).querySelector(
`.${this.props.classPrefix}Modal-content`
);
}
renderBody(body: SchemaNode, key?: any): React.ReactNode { renderBody(body: SchemaNode, key?: any): React.ReactNode {
let {render, store} = this.props; let {render, store} = this.props;
@ -306,6 +313,7 @@ export default class Dialog extends React.Component<DialogProps, DialogState> {
disabled: (body && (body as any).disabled) || store.loading, disabled: (body && (body as any).disabled) || store.loading,
onAction: this.handleAction, onAction: this.handleAction,
onFinished: this.handleChildFinished, onFinished: this.handleChildFinished,
popOverContainer: this.getPopOverContainer,
affixOffsetTop: 0, affixOffsetTop: 0,
onChange: this.handleFormChange, onChange: this.handleFormChange,
onInit: this.handleFormInit, onInit: this.handleFormInit,

View File

@ -346,7 +346,7 @@ export default class PickerControl extends React.PureComponent<
} }
@autobind @autobind
renderBody() { renderBody({popOverContainer}: any) {
const { const {
render, render,
selectedOptions, selectedOptions,
@ -363,7 +363,8 @@ export default class PickerControl extends React.PureComponent<
options: options, options: options,
multiple, multiple,
onSelect: embed ? this.handleChange : undefined, onSelect: embed ? this.handleChange : undefined,
ref: this.crudRef ref: this.crudRef,
popOverContainer
}) as JSX.Element; }) as JSX.Element;
} }