1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-24 01:18:01 +02:00

Don't use fallback functions for dragging

This commit is contained in:
Thomas Heartman 2025-03-20 13:29:49 +01:00
parent 90eed05296
commit 676757f914
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
3 changed files with 11 additions and 13 deletions

View File

@ -87,6 +87,8 @@ export const StrategyItemContainer: FC<StrategyItemContainerProps> = ({
? ({ children }) => <Link to={strategy.links.edit}>{children}</Link> ? ({ children }) => <Link to={strategy.links.edit}>{children}</Link>
: ({ children }) => <> {children} </>; : ({ children }) => <> {children} </>;
console.log('ondragstart', onDragStart);
return ( return (
<Box <Box
className={strategy.disabled ? disabledStrategyClassName : ''} className={strategy.disabled ? disabledStrategyClassName : ''}

View File

@ -34,8 +34,6 @@ type ProjectEnvironmentStrategyDraggableItemProps = {
onDragEnd?: () => void; onDragEnd?: () => void;
}; };
const onDragNoOp = () => () => {};
export const ProjectEnvironmentStrategyDraggableItem = ({ export const ProjectEnvironmentStrategyDraggableItem = ({
className, className,
strategy, strategy,
@ -43,9 +41,9 @@ export const ProjectEnvironmentStrategyDraggableItem = ({
environmentName, environmentName,
otherEnvironments, otherEnvironments,
isDragging, isDragging,
onDragStartRef = onDragNoOp, onDragStartRef,
onDragOver = onDragNoOp, onDragOver,
onDragEnd = onDragNoOp, onDragEnd,
}: ProjectEnvironmentStrategyDraggableItemProps) => { }: ProjectEnvironmentStrategyDraggableItemProps) => {
const projectId = useRequiredPathParam('projectId'); const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId'); const featureId = useRequiredPathParam('featureId');
@ -79,7 +77,7 @@ export const ProjectEnvironmentStrategyDraggableItem = ({
className={className} className={className}
key={strategy.id} key={strategy.id}
ref={ref} ref={ref}
onDragOver={onDragOver(ref, index)} onDragOver={onDragOver?.(ref, index)}
sx={{ opacity: isDragging ? '0.5' : '1' }} sx={{ opacity: isDragging ? '0.5' : '1' }}
> >
<StrategyDraggableItem <StrategyDraggableItem

View File

@ -8,8 +8,6 @@ import { Box } from '@mui/material';
import type { IFeatureStrategy } from 'interfaces/strategy'; import type { IFeatureStrategy } from 'interfaces/strategy';
import { StrategyItem } from './StrategyItem/StrategyItem'; import { StrategyItem } from './StrategyItem/StrategyItem';
const onDragNoOp = () => () => {};
type StrategyDraggableItemProps = { type StrategyDraggableItemProps = {
headerItemsRight: ReactNode; headerItemsRight: ReactNode;
strategy: IFeatureStrategy; strategy: IFeatureStrategy;
@ -30,9 +28,9 @@ export const StrategyDraggableItem = ({
strategy, strategy,
index, index,
isDragging, isDragging,
onDragStartRef = onDragNoOp, onDragStartRef,
onDragOver = onDragNoOp, onDragOver,
onDragEnd = onDragNoOp, onDragEnd,
headerItemsRight, headerItemsRight,
}: StrategyDraggableItemProps) => { }: StrategyDraggableItemProps) => {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
@ -41,13 +39,13 @@ export const StrategyDraggableItem = ({
<Box <Box
key={strategy.id} key={strategy.id}
ref={ref} ref={ref}
onDragOver={onDragOver(ref, index)} onDragOver={onDragOver?.(ref, index)}
sx={{ opacity: isDragging ? '0.5' : '1' }} sx={{ opacity: isDragging ? '0.5' : '1' }}
> >
<StrategyItem <StrategyItem
headerItemsRight={headerItemsRight} headerItemsRight={headerItemsRight}
strategy={strategy} strategy={strategy}
onDragStart={onDragStartRef(ref, index)} onDragStart={onDragStartRef?.(ref, index)}
onDragEnd={onDragEnd} onDragEnd={onDragEnd}
/> />
</Box> </Box>