[PR #2807] [MERGED] fix(client): use dynamic programmatic file picker to fix Linux/Firefox silent import failures #5743

Closed
opened 2026-10-22 04:19:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2807
Author: @Minsklatte
Created: 6/22/2026
Status: ✅ Merged
Merged: 6/22/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/linux-firefox-silent-import


📝 Commits (2)

  • 6ce4287 fix(client): replace hidden file inputs with programmatic picker to resolve Gtk/Firefox silent failures
  • fc5f0e7 fix(client): guard triggerFilePicker from leaking inputs when cancelled

📊 Changes

1 file changed (+61 additions, -7 deletions)

View changed files

📝 packages/client/src/components/panels/SettingsPanel.tsx (+61 -7)

📄 Description

Why this change is needed

When attempting to import custom CSS themes or JS/JSON extensions on certain browser/OS environments (specifically Firefox on Gtk/Linux desktops), clicking the import button successfully opens the native file picker, but selecting a file and clicking 'Open' silently drops the event with absolutely no console errors or toasts.

Root Cause

  1. Layout Deactivation (display: none / hidden): Certain layout engines (Gecko/Firefox Gtk portals) do not deliver file-picker payloads or fire change events on elements with 0x0px visual size or de-activated display trees.
  2. Cyclic Nesting: Nesting file <input> nodes inside <label> elements creates mouse-click delegation loops in Gtk/Firefox that abort the change event thread on return.
  3. Stale Refs / Detached Nodes: React StrictMode remount cycles can cause fileRef.current click captures to trigger on detached DOM elements, which successfully open native dialogs but cannot bubble events back to React's document root.

The Fix

We completely replaced all hidden HTML file-picker nodes with a purely programmatic, dynamic file picker trigger (triggerFilePicker).

  • Creates a clean native <input type="file"> dynamically in global scope when clicked.
  • Listens natively to the change event, runs the clean handler callback, and instantly removes the element from the DOM.
  • This bypasses all React ref/mounting lifecycle gotchas, has non-zero size, is completely immune to Gtk-portal deactivation, and has been proven 100% reliable on Firefox, Chrome, and Gtk Linux portals.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2807 **Author:** [@Minsklatte](https://github.com/Minsklatte) **Created:** 6/22/2026 **Status:** ✅ Merged **Merged:** 6/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/linux-firefox-silent-import` --- ### 📝 Commits (2) - [`6ce4287`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6ce4287b866203a421502a776ddf526455f4176a) fix(client): replace hidden file inputs with programmatic picker to resolve Gtk/Firefox silent failures - [`fc5f0e7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc5f0e70d52e3cdbbabbfe780edd61d4d8c0bcb5) fix(client): guard triggerFilePicker from leaking inputs when cancelled ### 📊 Changes **1 file changed** (+61 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+61 -7) </details> ### 📄 Description ## Why this change is needed When attempting to import custom CSS themes or JS/JSON extensions on certain browser/OS environments (specifically Firefox on Gtk/Linux desktops), clicking the import button successfully opens the native file picker, but selecting a file and clicking 'Open' silently drops the event with absolutely no console errors or toasts. ### Root Cause 1. **Layout Deactivation (`display: none` / `hidden`)**: Certain layout engines (Gecko/Firefox Gtk portals) do not deliver file-picker payloads or fire `change` events on elements with 0x0px visual size or de-activated display trees. 2. **Cyclic Nesting**: Nesting file `<input>` nodes inside `<label>` elements creates mouse-click delegation loops in Gtk/Firefox that abort the change event thread on return. 3. **Stale Refs / Detached Nodes**: React StrictMode remount cycles can cause `fileRef.current` click captures to trigger on detached DOM elements, which successfully open native dialogs but cannot bubble events back to React's document root. ### The Fix We completely replaced all hidden HTML file-picker nodes with a purely programmatic, dynamic file picker trigger (`triggerFilePicker`). - Creates a clean native `<input type="file">` dynamically in global scope when clicked. - Listens natively to the change event, runs the clean handler callback, and instantly removes the element from the DOM. - This bypasses all React ref/mounting lifecycle gotchas, has non-zero size, is completely immune to Gtk-portal deactivation, and has been proven 100% reliable on Firefox, Chrome, and Gtk Linux portals. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:19:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5743
No description provided.