Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uncollapse link and clicking on images #1705

Merged
merged 6 commits into from
Dec 27, 2024

Conversation

Kuuuube
Copy link
Member

@Kuuuube Kuuuube commented Dec 27, 2024

Fixes #1704

Adds back the collapsed image [Image] text and opens the original image in a new tab when clicked on. Opening the original image is important since the canvas can be scaled different (often smaller) and is less useful to open to see in a new tab.

content-visibility: auto; cuts off the preview thumbnail display for collapsed images if it is at the bottom of an entry.

openMediaInTab is similar to the old _getMediaData

async _getMediaData(path, dictionary) {
const token = this._token;
const datas = await this._display.application.api.getMedia([{path, dictionary}]);
if (token === this._token && datas.length > 0) {
const data = datas[0];
const buffer = base64ToArrayBuffer(data.content);
const blob = new Blob([buffer], {type: data.mediaType});
const url = URL.createObjectURL(blob);
return {data, url};
}
return null;

Double check on this._contentManager instanceof DisplayContentManager because typescript has the memory of a goldfish and forgets that it was checked in the previous if statement.

@Kuuuube Kuuuube added kind/bug The issue or PR is regarding a bug area/ui-ux The issue or PR is related to UI/UX/Design regression This issue or PR is related to a regression labels Dec 27, 2024
@Kuuuube Kuuuube requested a review from a team as a code owner December 27, 2024 17:32
@Kuuuube Kuuuube changed the title Fix uncollapse link Fix uncollapse link and clicking on images Dec 27, 2024
Copy link

codspeed-hq bot commented Dec 27, 2024

CodSpeed Performance Report

Merging #1705 will not alter performance

Comparing Kuuuube:fix-uncollapse-link (112a429) with master (58ecbeb)

Summary

✅ 3 untouched benchmarks

Copy link

github-actions bot commented Dec 27, 2024

Playwright test results

passed  5 passed

Details

stats  5 tests across 4 suites
duration  1 minute, 34 seconds
commit  7d4ae00

@jamesmaa jamesmaa added this pull request to the merge queue Dec 27, 2024
Merged via the queue into yomidevs:master with commit 7d4ae00 Dec 27, 2024
11 checks passed
@djahandarie
Copy link
Collaborator

Double check on this._contentManager instanceof DisplayContentManager because typescript has the memory of a goldfish and forgets that it was checked in the previous if statement.

(You may already know this but) it's actually correct, because in theory the contents of this._contentManager could change between when the event listener is added and when it triggers. We know that it won't because we clear the elements and their event listeners when we switch the popup contents / the content manager, but there is no guarantee of it, and indeed one could imagine a bug being introduced at some point that causes that invariant to not be true since there is no type safety regarding ordering of stuff like this.

@djahandarie
Copy link
Collaborator

BTW, removing content-visibility:auto introduces a fairly significant performance degradation (maybe 5x slowly popup render time for a big popup). I'll try to think if there's someway to restore it without causing a bug here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-ux The issue or PR is related to UI/UX/Design kind/bug The issue or PR is regarding a bug regression This issue or PR is related to a regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collapsible images vanish when used
3 participants