Skip to content

Commit

Permalink
fix(ui): jumping hasmany uploads when form is submitting or in readon…
Browse files Browse the repository at this point in the history
…ly mode (#9198)
  • Loading branch information
paulpopus authored Nov 14, 2024
1 parent 2d7626c commit 315b4e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/ui/src/fields/Upload/HasMany/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
position: relative;
max-width: 100%;

&__drag {
&[aria-disabled='true'] {
&:hover {
cursor: default;
}
}
}

&__draggable-rows {
display: flex;
flex-direction: column;
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/fields/Upload/HasMany/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function UploadComponentHasMany(props: Props) {
}

return (
<DraggableSortableItem disabled={!isSortable} id={id} key={id}>
<DraggableSortableItem disabled={!isSortable || readonly} id={id} key={id}>
{(draggableSortableItemProps) => (
<div
className={[
Expand All @@ -93,7 +93,7 @@ export function UploadComponentHasMany(props: Props) {
}}
>
<UploadCard size="small">
{isSortable && draggableSortableItemProps && (
{draggableSortableItemProps && (
<div
className={`${baseClass}__drag`}
{...draggableSortableItemProps.attributes}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/fields/Upload/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function UploadInput(props: UploadInputProps) {
const loadedValueDocsRef = React.useRef<boolean>(false)

const canCreate = useMemo(() => {
if (readOnly || !allowCreate) {
if (!allowCreate) {
return false
}

Expand Down Expand Up @@ -558,7 +558,7 @@ export function UploadInput(props: UploadInputProps) {
/>
</div>

{canCreate && (
{canCreate && !readOnly && (
<p className={`${baseClass}__dragAndDropText`}>
{t('general:or')} {t('upload:dragAndDrop')}
</p>
Expand Down

0 comments on commit 315b4e5

Please sign in to comment.