Fixes Strange behaviour when reordering options of select field (#6103) (#6339)

fixes #6103

---------

Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
This commit is contained in:
Faisal-imtiyaz123
2024-07-22 18:03:02 +05:30
committed by GitHub
parent f24536c115
commit 284e75791c
2 changed files with 4 additions and 1 deletions

View File

@ -218,6 +218,7 @@ export const SettingsDataModelFieldSelectForm = ({
<> <>
{options.map((option, index) => ( {options.map((option, index) => (
<DraggableItem <DraggableItem
isInsideScrollableContainer
key={option.id} key={option.id}
draggableId={option.id} draggableId={option.id}
index={index} index={index}

View File

@ -7,6 +7,7 @@ type DraggableItemProps = {
isDragDisabled?: boolean; isDragDisabled?: boolean;
index: number; index: number;
itemComponent: JSX.Element; itemComponent: JSX.Element;
isInsideScrollableContainer?: boolean;
}; };
export const DraggableItem = ({ export const DraggableItem = ({
@ -14,6 +15,7 @@ export const DraggableItem = ({
isDragDisabled = false, isDragDisabled = false,
index, index,
itemComponent, itemComponent,
isInsideScrollableContainer,
}: DraggableItemProps) => { }: DraggableItemProps) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
@ -36,7 +38,7 @@ export const DraggableItem = ({
style={{ style={{
...draggableStyle, ...draggableStyle,
left: 'auto', left: 'auto',
top: 'auto', ...(isInsideScrollableContainer ? {} : { top: 'auto' }),
transform: draggableStyle?.transform?.replace( transform: draggableStyle?.transform?.replace(
/\(-?\d+px,/, /\(-?\d+px,/,
'(0,', '(0,',