Ability to Open New Launch Params in Existing PWA Window
Closed this issue · 3 comments
Issue
I am working on a text editing PWA, and I just recently implemented this API so users can import files directly from the file system. The editor can edit multiple files within the same window, and the user can navigate to each one from a dedicated button on the page. This works great with opening files from the file system with the new "launchQueue" function from this API. However, I noticed that if a PWA window is already open, the new "launchQueue" request will always open a new PWA window, rather than sending the second request to the existing PWA window. I would like to suggest that new "launchQueue" requests should have the ability to open in an existing PWA window, rather than always creating a second window.
See It In Action
Links for information and issue testing:
Smart Text Editor - Repository
Smart Text Editor - GitHub Pages
This is the guide I used to implement the API: Article on web.dev
Requirements:
- File Handling API flag must be enabled within Chrome's flags page (chrome://flags/#file-handling-api)
- Smart Text Editor PWA must be in the installed state
Steps to Reproduce
-
Open a set of files from the file system with Smart Text Editor.
- Notice that a window was created, and the text files have been loaded and are ready for editing.
- Supported file extensions: .txt, .html, .css, .js, .json, .webmanifest, .md, .mcmeta
-
Go back to the file system, and open a different selection of files with Smart Text Editor.
- This time, these files will open a new Smart Text Editor window, rather than opening as new tabs within the first window.
launch events and a subset of that in declarative link capturing are two proposals to address this.
Thanks for the info, those definitely appear to be the same or similar to the issue I'm running into.
Thanks @mkruisselbrink for pointing folks there.
Yes, we definitely want to solve this holistically for all PWAs and not special-case file handling here (in fact, the reason we called it "launchQueue" even though it currently only gets one thing in it, is so that when we do DLC, we'll be able to target an existing window and append things to the queue).
Specifically, if we implement declarative link capturing as designed, you would be able to get this behaviour by setting "capture_links": "existing_client_event"
in the manifest, which would cause file handlers to a) try to find an existing window, and if found, focus it, push a new entry to launchQueue
, and fire a launch
event on that page, and b) if no existing window is found, create a new window and populate its launchQueue
. I think that's what you want.
As such, closing this; please follow the DLC work on the WICG/sw-launch repo for updates.