Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

Revert "fix(editor): open description images on click, like comment images (MUL-8957) (#10296)" (#10336)

Jiayuan Zhang78ae0ecdc8d5
diff --git a/packages/views/editor/attachment.test.tsx b/packages/views/editor/attachment.test.tsx
index fe6b279dde..7a18c54f27 100644
--- a/packages/views/editor/attachment.test.tsx
+++ b/packages/views/editor/attachment.test.tsx
@@ -254,43 +254,6 @@ describe("Attachment — image dispatch", () => {
expect(onDelete).toHaveBeenCalled();
});
- it("editable image opens the preview on click, like a read-only one (MUL-8957)", () => {
- renderWithQuery(
- <Attachment
- attachment={{
- kind: "url",
- url: "https://external.example/shot.png",
- filename: "",
- forceKind: "image",
- }}
- editable
- />,
- );
- const figure = document.querySelector(".image-figure") as HTMLElement;
- expect(figure.getAttribute("data-clickable")).toBe("true");
- fireEvent.click(figure);
- expect(screen.getByRole("dialog").querySelector("img")).toBeTruthy();
- });
-
- it("uploading image stays inert to clicks", () => {
- renderWithQuery(
- <Attachment
- attachment={{
- kind: "url",
- url: "https://external.example/shot.png",
- filename: "",
- forceKind: "image",
- uploading: true,
- }}
- editable
- />,
- );
- const figure = document.querySelector(".image-figure") as HTMLElement;
- expect(figure.hasAttribute("data-clickable")).toBe(false);
- fireEvent.click(figure);
- expect(screen.queryByRole("dialog")).toBeNull();
- });
-
it("url-only image resolves to a record via context and uses its id for download", () => {
const att = makeRecord({
filename: "from-resolver.png",
diff --git a/packages/views/editor/attachment.tsx b/packages/views/editor/attachment.tsx
index f47f71ea42..d38c7afaa9 100644
--- a/packages/views/editor/attachment.tsx
+++ b/packages/views/editor/attachment.tsx
@@ -493,12 +493,12 @@ function ImageAttachmentView({
}
};
- // Click on figure opens the preview on every surface once the upload has
- // settled, editors included: an issue description is always an editor, and
- // its images must open the same way a comment's do. The CSS rule
- // `.image-figure[data-clickable="true"] { cursor: zoom-in }` keys off this
- // same flag for the cursor affordance.
- const clickable = !uploading;
+ // Click on figure opens the preview only in non-editor / non-uploading
+ // surfaces — inside the editor we let ProseMirror own the click for
+ // selection / cursor placement and route preview through the explicit
+ // Maximize button. The CSS rule `.image-figure[data-clickable="true"] {
+ // cursor: zoom-in }` keys off this same flag for the cursor affordance.
+ const clickable = !editable && !uploading;
// An image that has not loaded has no size of its own (the figure shrinks
// to it), so its box is reserved up front: from its pixel size when known,
diff --git a/packages/views/editor/extensions/image-view.tsx b/packages/views/editor/extensions/image-view.tsx
index 4babf7d19a..39977b077b 100644
--- a/packages/views/editor/extensions/image-view.tsx
+++ b/packages/views/editor/extensions/image-view.tsx
@@ -5,42 +5,24 @@
*
* Thin wrapper around the unified `<Attachment>` dispatcher. All rendering
* (figure, hover toolbar, lightbox/preview) lives there. The NodeView only
- * forwards Tiptap's editor-context hints (editable, selected, deleteNode) and
- * keeps a click-to-view from leaving the image selected.
+ * forwards Tiptap's editor-context hints (editable, selected, deleteNode).
*/
import { NodeViewWrapper } from "@tiptap/react";
import type { NodeViewProps } from "@tiptap/react";
-import { Selection } from "@tiptap/pm/state";
import { Attachment } from "../attachment";
-function ImageView({ node, editor, selected, deleteNode, getPos }: NodeViewProps) {
+function ImageView({ node, editor, selected, deleteNode }: NodeViewProps) {
const src = (node.attrs.src as string) || "";
const alt = (node.attrs.alt as string) || "";
const uploading = node.attrs.uploading as boolean;
const width = (node.attrs.width as number | null) ?? undefined;
const height = (node.attrs.height as number | null) ?? undefined;
- // A click on the image opens the viewer, but ProseMirror has already
- // node-selected it by then. Left selected, the first keystroke after the
- // viewer hands focus back would replace the image, so the caret moves to
- // the nearest text instead.
- const releaseSelection = () => {
- const pos = getPos();
- if (typeof pos !== "number") return;
- const { state, view } = editor;
- const $after = state.doc.resolve(pos + node.nodeSize);
- const next =
- Selection.findFrom($after, 1, true) ?? Selection.findFrom($after, -1, true);
- if (next) view.dispatch(state.tr.setSelection(next));
- };
-
// <Attachment> emits its own .image-node wrapper, so the NodeViewWrapper
// stays unclassed — no double image-node.
return (
- <NodeViewWrapper
- onClick={editor.isEditable && !uploading && src ? releaseSelection : undefined}
- >
+ <NodeViewWrapper>
<Attachment
attachment={{
kind: "url",