Skip to content

Image lightbox navigation - #31932

Closed
Snamhdaen wants to merge 11 commits into
element-hq:developfrom
Snamhdaen:feat/lightbox-image-navigation
Closed

Snamhdaen wants to merge 11 commits into
element-hq:developfrom
Snamhdaen:feat/lightbox-image-navigation

Conversation

@Snamhdaen

Copy link
Copy Markdown

Checklist

I tried my hand at #337
I don't really know whether the handling of media sorting I did here is what you want, please advise.

@Snamhdaen
Snamhdaen requested a review from a team as a code owner January 31, 2026 23:31
@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Jan 31, 2026
@t3chguy t3chguy changed the title Feat/lightbox image navigation Image lightbox navigation Feb 2, 2026
@t3chguy

t3chguy commented Feb 2, 2026

Copy link
Copy Markdown
Member

Linter and other CI checks pass.

They do not

@Snamhdaen

Copy link
Copy Markdown
Author

Linter and other CI checks pass.

They do not

I was under the impression they did, but see now that they don't. I will try to fix this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on with this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, seems to be the result of prettier write. I didn't change anything.

@t3chguy t3chguy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good if you could include some screenshots so design can review it

Comment on lines +68 to +71
onPrev?(): void;
onNext?(): void;
hasPrev?: boolean;
hasNext?: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these booleans not be implied by the presence of onPrev/onNext respectively?

Need doc comments also

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can do without them. We could keep them internally in NavigableImageViewDialog but not forward them as props like so:

onPrev={hasPrev ? onPrev : undefined}
onNext={hasNext ? onNext : undefined}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just build params for NavigableImageviewDialog here instead? Otherwise half the params get discard, e.g. params.src

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree.

@@ -0,0 +1,293 @@
/*
Copyright 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank copyright

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the convention to put there? My name? Element?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes your name


useEffect(() => {
let cancelled = false;
const controller = new AbortController();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This controller doesn't seem to be used for anything?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx. I will remove it. Was left over from trying to fix a bug where backpagination lost its place in the timeline. I added a more robust (I hope) of paginateBackwards.

@@ -0,0 +1,190 @@
/*
Copyright 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank copyright

Comment on lines +33 to +36
if (!ev || ev.isRedacted()) return false;
if (ev.getType() !== EventType.RoomMessage) return false;
const c = ev.getContent<ImageContent>();
return c?.msgtype === MsgType.Image;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is sufficient, given some image events aren't rendered as image events for security, e.g. ones which lie about their mimetype. Iirc you need to check if the renderer for the event would be MImageBody instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I now model the behaviour from MImageBody.render(). Events that will not be rendered as an image shouldnt be navigated as one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good spot, feel free to extract the logic to share it. I was wrong that checking the renderer alone was sufficient.

@t3chguy

t3chguy commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

This PR also seems to break rendering of SVGs.

Screen.Recording.2026-02-05.at.16.13.01.mov

poor video, but I switch tabs to a develop build and it works fine half way through

@Snamhdaen

Copy link
Copy Markdown
Author

This PR also seems to break rendering of SVGs.
Screen.Recording.2026-02-05.at.16.13.01.mov

poor video, but I switch tabs to a develop build and it works fine half way through

Ooh good catch, that's not good of course. But I think it works now. The dialog swapped the src to an unrenderable blob URL. My test svgs now render fine. I will upload the fix tomorrow.

@Snamhdaen

Copy link
Copy Markdown
Author
grafik grafik

First picture is an svg at the start of timeline with right arrow not visible. Second picture is in the middle of the timeline with both arrows visible.

@t3chguy
t3chguy requested a review from a team February 6, 2026 09:02
Comment on lines +70 to +71
/*hasPrev?: boolean;
hasNext?: boolean;*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't leave commented code, it adds no value

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintentional, will remove.

@Snamhdaen

Copy link
Copy Markdown
Author

I don't see any way how this PR interferes with the wysiwyg_composer test...

@t3chguy

t3chguy commented Feb 6, 2026

Copy link
Copy Markdown
Member

That test is flaky, as documented in #31227

@Half-Shot

Copy link
Copy Markdown
Member

@Snamhdaen hey 👋 Looks like this is close? Would you be able to solve the merge conflicts & slightly improve upon the test coverage.

@Snamhdaen

Copy link
Copy Markdown
Author

@Snamhdaen hey 👋 Looks like this is close? Would you be able to solve the merge conflicts & slightly improve upon the test coverage.

Will be able to work on this in the coming days.

@gaelledel gaelledel left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks very much for the contribution.

1/ Currently you are displaying the Next/Back buttons over the image. I wonder if instead, we could display them so not over the image. In the case of a timeline lightbox, the buttons should appear on either side (outside) of the image.

Your impl. below :
Image

2/ The buttons being used are not quite right especially in terms of contrast and size. Could we use Quick Action Large buttons Dark Theme instead ? https://compound.element.io/?path=/docs/compound-web_button-actions--docs

3/ Could we have the tooltips to read: Left button = Previous / Right button = Next

@t3chguy t3chguy mentioned this pull request Apr 13, 2026
2 of 5 tasks
@dbkr

dbkr commented Apr 30, 2026

Copy link
Copy Markdown
Member

Since it's been 2 months since we've heard from the contributor and 28 days since Gaelle's review, I think this one is stale unfortunately.As always, code is here if someone has the motivation to pick it up.

@dbkr dbkr closed this Apr 30, 2026
kcfancher added a commit to kcfancher/element-web that referenced this pull request Oct 17, 2026
kcfancher added a commit to kcfancher/element-web that referenced this pull request Oct 17, 2026
kcfancher added a commit to kcfancher/element-web that referenced this pull request Oct 17, 2026
Move navigation buttons beside the image, preserve focus at boundaries, and disable navigation during pagination. Reset zoom, rotation, and panning when the image changes.

Addresses gaelledel's design review (points 1 and 2) on element-hq#31932.
@kcfancher

Copy link
Copy Markdown

I've updated @Snamhdaen's PR, implemented changes fromt the review, and opened a new PR #35507.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Enhancement Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants