refactor: should not trigger event of row when clicking in drawer (#2400)

* refactor: should not fire event if row when clicking in drawer

* refactor: rename
This commit is contained in:
被雨水过滤的空气-Rain 2023-08-04 21:31:50 +08:00 committed by GitHub
parent e3e4e63146
commit 8615804b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 6 deletions

View File

@ -128,7 +128,7 @@ export const Action: ComposedAction = observer(
>
{popover && <RecursionField basePath={field.address} onlyRenderProperties schema={fieldSchema} />}
{!popover && renderButton()}
{!popover && <div onClick={(e) => e.stopPropagation()}>{props.children}</div>}
{!popover && props.children}
{element}
</ActionContextProvider>,
);

View File

@ -22,7 +22,7 @@ import {
import { useACLFieldWhitelist } from '../../../acl/ACLProvider';
import { useToken } from '../__builtins__';
import { ColumnFieldProvider } from './components/ColumnFieldProvider';
import { extractIndex, isCollectionFieldComponent, isColumnComponent } from './utils';
import { extractIndex, isCollectionFieldComponent, isColumnComponent, isPortalInBody } from './utils';
const useArrayField = (props) => {
const field = useField<ArrayField>();
@ -239,7 +239,12 @@ export const Table: any = observer(
if (onClickRow) {
onRow = (record) => {
return {
onClick: () => onClickRow(record, setSelectedRow, selectedRow),
onClick: (e) => {
if (isPortalInBody(e.target)) {
return;
}
onClickRow(record, setSelectedRow, selectedRow);
},
};
};
highlightRow = css`
@ -323,9 +328,9 @@ export const Table: any = observer(
.nb-read-pretty-input-number {
text-align: right;
}
.ant-color-picker-trigger{
position:absolute;
top:50%;
.ant-color-picker-trigger {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
`,

View File

@ -17,3 +17,17 @@ export function extractIndex(str) {
});
return numbers.join('.');
}
/**
* DOM createPortal body
* @param domNode DOM
*/
export const isPortalInBody = (dom: HTMLElement) => {
while (dom) {
if (dom.id === 'root') {
return false;
}
dom = dom.parentNode as HTMLElement;
}
return true;
};