daedalOS icon indicating copy to clipboard operation
daedalOS copied to clipboard

Bug: PDF Viewer Window Title Not Updating When Dragging Same File

Open zjuguxi opened this issue 1 year ago • 6 comments

Description

When dragging and dropping PDF files in the PDF viewer application, the window title does not update correctly in the following scenario:

  1. Drag file a.pdf into the PDF viewer -> Title updates correctly
  2. Drag file b.pdf into the PDF viewer -> Title updates correctly
  3. Drag file a.pdf again into the PDF viewer -> Title remains as b.pdf even though the content shows a.pdf

Image

Steps to Reproduce

  1. Open the PDF viewer application
  2. Drag and drop a.pdf into the viewer
  3. Drag and drop b.pdf into the viewer
  4. Drag and drop a.pdf again into the viewer

Expected Behavior

The window title should update to reflect the currently displayed PDF file name, regardless of whether it's the same file being dragged again.

Actual Behavior

The window title remains stuck on the previous file name (b.pdf) even though the content has changed to show a.pdf.

Details

The issue appears to be in the title update logic in components/apps/PDF/usePDF.ts. The title update is dependent on the url state change, but when dragging the same file, the URL might not trigger a state update, causing the title to remain unchanged.

zjuguxi avatar Apr 04 '25 17:04 zjuguxi

I am not sure why it did this for you but I am unable to re-create this. For me it updates every time. Did you drag each PDF from within the app or outside of it?

DustinBrett avatar Apr 07 '25 03:04 DustinBrett

I am not sure why it did this for you but I am unable to re-create this. For me it updates every time. Did you drag each PDF from within the app or outside of it?

I add files to desktop, double click one to open, then drag and drop the second.

Scenario that probably cannot trigger the bug: If one PDF has metadata while the other doesn't. It will not reproduce.

(Edit: I also found for some PDFs with metadata, I cannot reproduce either. The key point seems to be metadata.title, not the whole metadata, but not sure yet.)

I can reproduce it on both your website and my local environment after about 3 times dragging and dropping.

zjuguxi avatar Apr 07 '25 17:04 zjuguxi

Could you perhaps attach some example pdf's? I am not able to make this happen still, I tried 5 example pdf's which I downloaded.

DustinBrett avatar Apr 17 '25 04:04 DustinBrett

a.pdf b.pdf

I used these two PDFs. They can reproduce the bug on your website. Drag one into PDF viewer (or double click to open), then drag the other in. Do this twice. Let me know if you can reproduce or not.

zjuguxi avatar Apr 21 '25 23:04 zjuguxi

I am able to reproduce some effect but it seems to be larger than the titles, the entire PDF is not loaded properly in some cases. I will dig further into this and also I have a long term plan to change how PDF loading works to be more efficent.

DustinBrett avatar Apr 22 '25 06:04 DustinBrett

I've improved the loading logic so hopefully this fixes the issue.

https://github.com/DustinBrett/daedalOS/commit/0405c6ba7dec6a7706e188754d7c70ee0a38c7ba

DustinBrett avatar Apr 23 '25 04:04 DustinBrett