mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
fix: table row button drag-and-drop issue (#6544)
* fix: table row button drag-and-drop issue * fix: bug * fix: bug
This commit is contained in:
parent
c2f97a9300
commit
7f1ede84d9
@ -16,16 +16,19 @@ import Action from './Action';
|
|||||||
import { ComposedAction } from './types';
|
import { ComposedAction } from './types';
|
||||||
import { Icon } from '../../../icon';
|
import { Icon } from '../../../icon';
|
||||||
|
|
||||||
const WrapperComponent = ({ component: Component = 'a', icon, onlyIcon, children, ...restProps }: any) => {
|
const WrapperComponent = React.forwardRef(
|
||||||
return (
|
({ component: Component = 'a', icon, onlyIcon, children, ...restProps }: any, ref) => {
|
||||||
<Component {...restProps}>
|
return (
|
||||||
<Tooltip title={restProps.title}>
|
<Component ref={ref} {...restProps}>
|
||||||
<span style={{ marginRight: 3 }}>{icon && typeof icon === 'string' ? <Icon type={icon} /> : icon}</span>
|
<Tooltip title={restProps.title}>
|
||||||
</Tooltip>
|
<span style={{ marginRight: 3 }}>{icon && typeof icon === 'string' ? <Icon type={icon} /> : icon}</span>
|
||||||
{onlyIcon ? children[1] : children}
|
</Tooltip>
|
||||||
</Component>
|
{onlyIcon ? children[1] : children}
|
||||||
);
|
</Component>
|
||||||
};
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
WrapperComponent.displayName = 'WrapperComponentLink';
|
||||||
|
|
||||||
export const ActionLink: ComposedAction = withDynamicSchemaProps(
|
export const ActionLink: ComposedAction = withDynamicSchemaProps(
|
||||||
observer((props: any) => {
|
observer((props: any) => {
|
||||||
|
@ -45,9 +45,9 @@ export const Sortable = (props: any) => {
|
|||||||
const { draggable, droppable } = useContext(SortableContext);
|
const { draggable, droppable } = useContext(SortableContext);
|
||||||
const { isOver, setNodeRef } = droppable;
|
const { isOver, setNodeRef } = droppable;
|
||||||
const droppableStyle = { ...style };
|
const droppableStyle = { ...style };
|
||||||
|
const isLinkComponent = component === 'a' || component?.displayName === 'WrapperComponentLink';
|
||||||
if (isOver && draggable?.active?.id !== droppable?.over?.id) {
|
if (isOver && draggable?.active?.id !== droppable?.over?.id) {
|
||||||
droppableStyle[component === 'a' ? 'color' : 'background'] = getComputedColor(token.colorSettings);
|
droppableStyle[isLinkComponent ? 'color' : 'background'] = getComputedColor(token.colorSettings);
|
||||||
Object.assign(droppableStyle, overStyle);
|
Object.assign(droppableStyle, overStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,6 @@ export const SortableItem: React.FC<SortableItemProps> = React.memo((props) => {
|
|||||||
if (designable) {
|
if (designable) {
|
||||||
return <InternalSortableItem {...props} />;
|
return <InternalSortableItem {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return React.createElement(
|
return React.createElement(
|
||||||
component || 'div',
|
component || 'div',
|
||||||
_.omit(others, ['children', 'schema', 'overStyle', 'openMode', 'id', 'eid', 'removeParentsIfNoChildren']),
|
_.omit(others, ['children', 'schema', 'overStyle', 'openMode', 'id', 'eid', 'removeParentsIfNoChildren']),
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* This file is part of the NocoBase (R) project.
|
||||||
|
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||||
|
* Authors: NocoBase Team.
|
||||||
|
*
|
||||||
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||||
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
|
*/
|
||||||
|
|
||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { ISchema, useFieldSchema } from '@formily/react';
|
import { ISchema, useFieldSchema } from '@formily/react';
|
||||||
import { Action, ActionContextProvider, SchemaComponent, useCompile } from '@nocobase/client';
|
import { Action, ActionContextProvider, SchemaComponent, useCompile } from '@nocobase/client';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { NAMESPACE } from './constants';
|
import { NAMESPACE } from './constants';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { UploadOutlined } from '@ant-design/icons';
|
|
||||||
|
|
||||||
const importFormSchema: ISchema = {
|
const importFormSchema: ISchema = {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
@ -113,7 +121,6 @@ const importFormSchema: ISchema = {
|
|||||||
|
|
||||||
export const ImportAction = (props) => {
|
export const ImportAction = (props) => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const { t } = useTranslation(NAMESPACE);
|
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
|
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
@ -121,7 +128,7 @@ export const ImportAction = (props) => {
|
|||||||
return (
|
return (
|
||||||
<ActionContextProvider value={{ visible, setVisible, fieldSchema }}>
|
<ActionContextProvider value={{ visible, setVisible, fieldSchema }}>
|
||||||
<Action
|
<Action
|
||||||
icon={props.icon || <UploadOutlined />}
|
icon={props.icon || 'uploadoutlined'}
|
||||||
title={compile(fieldSchema?.title || "t('Import')")}
|
title={compile(fieldSchema?.title || "t('Import')")}
|
||||||
{...props}
|
{...props}
|
||||||
onClick={() => setVisible(true)}
|
onClick={() => setVisible(true)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user