mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-15 16:58:14 +00:00
fix: Fix glitchy iOS media attachment drag interactions (#35057)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Crowdin / Upload translations / upload-translations (push) Has been cancelled
This commit is contained in:
parent
af6ee7f230
commit
69f298731e
|
@ -22,10 +22,11 @@ import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||||
export const Upload: React.FC<{
|
export const Upload: React.FC<{
|
||||||
id: string;
|
id: string;
|
||||||
dragging?: boolean;
|
dragging?: boolean;
|
||||||
|
draggable?: boolean;
|
||||||
overlay?: boolean;
|
overlay?: boolean;
|
||||||
tall?: boolean;
|
tall?: boolean;
|
||||||
wide?: boolean;
|
wide?: boolean;
|
||||||
}> = ({ id, dragging, overlay, tall, wide }) => {
|
}> = ({ id, dragging, draggable = true, overlay, tall, wide }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const media = useAppSelector((state) =>
|
const media = useAppSelector((state) =>
|
||||||
(
|
(
|
||||||
|
@ -71,6 +72,7 @@ export const Upload: React.FC<{
|
||||||
<div
|
<div
|
||||||
className={classNames('compose-form__upload media-gallery__item', {
|
className={classNames('compose-form__upload media-gallery__item', {
|
||||||
dragging,
|
dragging,
|
||||||
|
draggable,
|
||||||
overlay,
|
overlay,
|
||||||
'media-gallery__item--tall': tall,
|
'media-gallery__item--tall': tall,
|
||||||
'media-gallery__item--wide': wide,
|
'media-gallery__item--wide': wide,
|
||||||
|
|
|
@ -116,6 +116,10 @@ export const UploadForm: React.FC = () => {
|
||||||
[dispatch, setActiveId],
|
[dispatch, setActiveId],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleDragCancel = useCallback(() => {
|
||||||
|
setActiveId(null);
|
||||||
|
}, [setActiveId]);
|
||||||
|
|
||||||
const accessibility: {
|
const accessibility: {
|
||||||
screenReaderInstructions: ScreenReaderInstructions;
|
screenReaderInstructions: ScreenReaderInstructions;
|
||||||
announcements: Announcements;
|
announcements: Announcements;
|
||||||
|
@ -158,32 +162,46 @@ export const UploadForm: React.FC = () => {
|
||||||
<div
|
<div
|
||||||
className={`compose-form__uploads media-gallery media-gallery--layout-${mediaIds.size}`}
|
className={`compose-form__uploads media-gallery media-gallery--layout-${mediaIds.size}`}
|
||||||
>
|
>
|
||||||
<DndContext
|
{mediaIds.size === 1 ? (
|
||||||
sensors={sensors}
|
<Upload
|
||||||
collisionDetection={closestCenter}
|
id={mediaIds.first()}
|
||||||
onDragStart={handleDragStart}
|
dragging={false}
|
||||||
onDragEnd={handleDragEnd}
|
draggable={false}
|
||||||
accessibility={accessibility}
|
tall
|
||||||
>
|
wide
|
||||||
<SortableContext
|
/>
|
||||||
items={mediaIds.toArray()}
|
) : (
|
||||||
strategy={rectSortingStrategy}
|
<DndContext
|
||||||
|
sensors={sensors}
|
||||||
|
collisionDetection={closestCenter}
|
||||||
|
onDragStart={handleDragStart}
|
||||||
|
onDragEnd={handleDragEnd}
|
||||||
|
onDragCancel={handleDragCancel}
|
||||||
|
onDragAbort={handleDragCancel}
|
||||||
|
accessibility={accessibility}
|
||||||
>
|
>
|
||||||
{mediaIds.map((id, idx) => (
|
<SortableContext
|
||||||
<Upload
|
items={mediaIds.toArray()}
|
||||||
key={id}
|
strategy={rectSortingStrategy}
|
||||||
id={id}
|
>
|
||||||
dragging={id === activeId}
|
{mediaIds.map((id, idx) => (
|
||||||
tall={mediaIds.size < 3 || (mediaIds.size === 3 && idx === 0)}
|
<Upload
|
||||||
wide={mediaIds.size === 1}
|
key={id}
|
||||||
/>
|
id={id}
|
||||||
))}
|
dragging={id === activeId}
|
||||||
</SortableContext>
|
tall={
|
||||||
|
mediaIds.size < 3 || (mediaIds.size === 3 && idx === 0)
|
||||||
|
}
|
||||||
|
wide={mediaIds.size === 1}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</SortableContext>
|
||||||
|
|
||||||
<DragOverlay>
|
<DragOverlay>
|
||||||
{activeId ? <Upload id={activeId as string} overlay /> : null}
|
{activeId ? <Upload id={activeId as string} overlay /> : null}
|
||||||
</DragOverlay>
|
</DragOverlay>
|
||||||
</DndContext>
|
</DndContext>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -708,7 +708,12 @@ body > [data-popper-placement] {
|
||||||
|
|
||||||
&__upload {
|
&__upload {
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: grab;
|
|
||||||
|
&.draggable {
|
||||||
|
will-change: transform, opacity;
|
||||||
|
touch-action: none;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
|
||||||
&.dragging {
|
&.dragging {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
@ -720,18 +725,6 @@ body > [data-popper-placement] {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__drag-handle {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
inset-inline-start: 0;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: $white;
|
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
padding: 8px 3px;
|
|
||||||
cursor: grab;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user