fix: ensure relationship field pills respect isSortable property (#6561)

This commit is contained in:
Jarrod Flesch
2024-05-29 15:12:42 -04:00
committed by GitHub
parent 92f458dad2
commit 425576be25
2 changed files with 14 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ export const MultiValue: React.FC<MultiValueProps<Option>> = (props) => {
const classes = [
baseClass,
className,
!isDisabled && 'draggable',
!isDisabled && isSortable && 'draggable',
isDragging && `${baseClass}--is-dragging`,
]
.filter(Boolean)
@@ -45,9 +45,13 @@ export const MultiValue: React.FC<MultiValueProps<Option>> = (props) => {
{...props}
className={classes}
innerProps={{
...innerProps,
...(isSortable
? {
...attributes,
...listeners,
}
: {}),
...innerProps,
onMouseDown: (e) => {
if (!disableMouseDown) {
// we need to prevent the dropdown from opening when clicking on the drag handle, but not when a modal is open (i.e. the 'Relationship' field component)
@@ -55,10 +59,12 @@ export const MultiValue: React.FC<MultiValueProps<Option>> = (props) => {
}
},
ref: setNodeRef,
style: {
style: isSortable
? {
transform,
...attributes?.style,
},
}
: {},
}}
/>
</React.Fragment>

View File

@@ -524,6 +524,7 @@ export const mapFields = (args: {
className: field.admin?.className,
disabled: field.admin?.disabled,
hasMany: field.hasMany,
isSortable: field.admin?.isSortable,
readOnly: field.admin?.readOnly,
relationTo: field.relationTo,
required: field.required,