fix: ensure relationship field pills respect isSortable property (#6561)
This commit is contained in:
@@ -32,7 +32,7 @@ export const MultiValue: React.FC<MultiValueProps<Option>> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
baseClass,
|
baseClass,
|
||||||
className,
|
className,
|
||||||
!isDisabled && 'draggable',
|
!isDisabled && isSortable && 'draggable',
|
||||||
isDragging && `${baseClass}--is-dragging`,
|
isDragging && `${baseClass}--is-dragging`,
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
@@ -45,9 +45,13 @@ export const MultiValue: React.FC<MultiValueProps<Option>> = (props) => {
|
|||||||
{...props}
|
{...props}
|
||||||
className={classes}
|
className={classes}
|
||||||
innerProps={{
|
innerProps={{
|
||||||
...innerProps,
|
...(isSortable
|
||||||
|
? {
|
||||||
...attributes,
|
...attributes,
|
||||||
...listeners,
|
...listeners,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...innerProps,
|
||||||
onMouseDown: (e) => {
|
onMouseDown: (e) => {
|
||||||
if (!disableMouseDown) {
|
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)
|
// 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,
|
ref: setNodeRef,
|
||||||
style: {
|
style: isSortable
|
||||||
|
? {
|
||||||
transform,
|
transform,
|
||||||
...attributes?.style,
|
...attributes?.style,
|
||||||
},
|
}
|
||||||
|
: {},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|||||||
@@ -524,6 +524,7 @@ export const mapFields = (args: {
|
|||||||
className: field.admin?.className,
|
className: field.admin?.className,
|
||||||
disabled: field.admin?.disabled,
|
disabled: field.admin?.disabled,
|
||||||
hasMany: field.hasMany,
|
hasMany: field.hasMany,
|
||||||
|
isSortable: field.admin?.isSortable,
|
||||||
readOnly: field.admin?.readOnly,
|
readOnly: field.admin?.readOnly,
|
||||||
relationTo: field.relationTo,
|
relationTo: field.relationTo,
|
||||||
required: field.required,
|
required: field.required,
|
||||||
|
|||||||
Reference in New Issue
Block a user