Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add file upload expanded window link for Firefox (#1491)

Leendert de Borst81e425633d0c
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/AttachmentUploader.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/AttachmentUploader.tsx
index a61155fb8..f073cda29 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/AttachmentUploader.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/AttachmentUploader.tsx
@@ -1,11 +1,15 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';
+
import type { Attachment } from '@/utils/dist/core/models/vault';
type AttachmentUploaderProps = {
attachments: Attachment[];
onAttachmentsChange: (attachments: Attachment[]) => void;
+ /** Item ID for edit mode - used to determine return path when opening expanded window */
+ itemId?: string;
}
/**
@@ -13,11 +17,15 @@ type AttachmentUploaderProps = {
*/
const AttachmentUploader: React.FC<AttachmentUploaderProps> = ({
attachments,
- onAttachmentsChange
+ onAttachmentsChange,
+ itemId
}) => {
const { t } = useTranslation();
const [statusMessage, setStatusMessage] = useState<string>('');
+ // Firefox requires popout for file uploads because it otherwise closes the popup when the native file dialog opens
+ const isFirefoxNarrowPopup = import.meta.env.FIREFOX && !PopoutUtility.isPopup();
+
/**
* Handles file selection and upload.
*/
@@ -94,17 +102,40 @@ const AttachmentUploader: React.FC<AttachmentUploaderProps> = ({
<h2 className="text-lg font-semibold mb-4 text-gray-900 dark:text-white">{t('common.attachments')}</h2>
<div className="space-y-4">
- <div>
- <input
- type="file"
- multiple
- onChange={handleFileSelection}
- className="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400"
- />
- {statusMessage && (
- <p className="mt-2 text-sm text-gray-500 dark:text-gray-400">{statusMessage}</p>
- )}
- </div>
+ {/* Firefox narrow popup: show message to use expanded window for file upload */}
+ {isFirefoxNarrowPopup ? (
+ <div className="border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-4 text-center">
+ <div className="text-sm text-gray-600 dark:text-gray-400">
+ <p className="mb-3">
+ {t('attachmentUploader.firefoxExpandRequired')}
+ </p>
+ <button
+ type="button"
+ onClick={() => {
+ const returnTo = itemId ? `/items/${itemId}` : '/items';
+ PopoutUtility.openInNewPopup(undefined, returnTo);
+ }}
+ className="inline-flex items-center px-3 py-1.5 text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 rounded-md transition-colors"
+ >
+ {t('attachmentUploader.openExpandedWindow')}
+ </button>
+ </div>
+ </div>
+ ) : (
+ /* Standard file input for Chrome/Edge/Safari and expanded Firefox */
+ <div>
+ <input
+ type="file"
+ multiple
+ onChange={handleFileSelection}
+ className="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400"
+ />
+ </div>
+ )}
+
+ {statusMessage && (
+ <p className="text-sm text-gray-500 dark:text-gray-400">{statusMessage}</p>
+ )}
{activeAttachments.length > 0 && (
<div>
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx
index c8505ec4b..a5e6d5349 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/Header.tsx
@@ -1,9 +1,10 @@
-import React from 'react';
+import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate, useLocation } from 'react-router-dom';
import Logo from '@/entrypoints/popup/components/Logo';
import { useApp } from '@/entrypoints/popup/context/AppContext';
+import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';
import ServerSyncIndicator from './ServerSyncIndicator';
@@ -39,6 +40,23 @@ const Header: React.FC<HeaderProps> = ({
return regex.test(location.pathname);
});
+ /**
+ * Handle back button click.
+ * Uses browser history if available, otherwise falls back to returnTo parameter
+ * (used when opening expanded popup from Firefox narrow popup).
+ */
+ const handleBack = useCallback((): void => {
+ // Check if we have a returnTo path (set when opening expanded popup)
+ const returnPath = PopoutUtility.getReturnPath();
+
+ // If we're in an expanded popup with a returnTo path and no history, use it
+ if (returnPath && PopoutUtility.isPopup() && window.history.length <= 2) {
+ navigate(returnPath);
+ } else {
+ navigate(-1);
+ }
+ }, [navigate]);
+
/**
* Handle settings.
*/
@@ -70,7 +88,7 @@ const Header: React.FC<HeaderProps> = ({
{currentRoute?.showBackButton ? (
<button
id="back"
- onClick={() => navigate(-1)}
+ onClick={handleBack}
className="flex items-center gap-2 hover:bg-gray-100 dark:hover:bg-gray-700 pr-2 pt-1.5 pb-1.5 rounded-lg group"
>
<div className="flex items-center">
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx
index 0386af67b..1d7027ed7 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx
@@ -1370,6 +1370,7 @@ const ItemAddEdit: React.FC = () => {
<AttachmentUploader
attachments={attachments}
onAttachmentsChange={setAttachments}
+ itemId={isEditMode ? id : undefined}
/>
)}
diff --git a/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.ts b/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.ts
index 4b99a44e2..0737a2390 100644
--- a/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.ts
+++ b/apps/browser-extension/src/entrypoints/popup/utils/PopoutUtility.ts
@@ -20,18 +20,36 @@ export class PopoutUtility {
return window.innerWidth > 390;
}
+ /**
+ * Get the return path from URL parameters (used for back navigation in expanded popups).
+ * @returns The return path if set, or null
+ */
+ public static getReturnPath(): string | null {
+ const urlParams = new URLSearchParams(window.location.search);
+ return urlParams.get('returnTo');
+ }
+
/**
* Open the current page in a new expanded popup window.
* @param path - The path to open in the popup (defaults to current path)
+ * @param returnTo - Optional path to return to when back button is pressed
*/
- public static openInNewPopup(path?: string): void {
+ public static openInNewPopup(path?: string, returnTo?: string): void {
const width = 800;
const height = 1000;
const left = window.screen.width / 2 - width / 2;
const top = window.screen.height / 2 - height / 2;
const currentPath = path || window.location.hash.replace('#', '');
- const popupUrl = `popup.html?expanded=true#${currentPath}`;
+
+ // Build URL with parameters
+ const params = new URLSearchParams();
+ params.set('expanded', 'true');
+ if (returnTo) {
+ params.set('returnTo', returnTo);
+ }
+
+ const popupUrl = `popup.html?${params.toString()}#${currentPath}`;
window.open(
popupUrl,
diff --git a/apps/browser-extension/src/i18n/locales/en.json b/apps/browser-extension/src/i18n/locales/en.json
index ba72e066f..2b60d30bd 100644
--- a/apps/browser-extension/src/i18n/locales/en.json
+++ b/apps/browser-extension/src/i18n/locales/en.json
@@ -294,7 +294,9 @@
"attachmentUploader": {
"uploading": "Uploading...",
"uploadSuccess": "Files uploaded successfully.",
- "deleteSuccess": "Attachment deleted successfully."
+ "deleteSuccess": "Attachment deleted successfully.",
+ "firefoxExpandRequired": "To upload files, use the expanded window.",
+ "openExpandedWindow": "Open Expanded Window"
},
"emails": {
"title": "Emails",
diff --git a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
index fbacc70d3..f2da53133 100644
--- a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
+++ b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
@@ -2724,7 +2724,7 @@ video {
.hover\:border-primary-500:hover {
--tw-border-opacity: 1;
- border-color: rgb(246 167 82 / var(--tw-border-opacity));
+ border-color: rgb(244 149 65 / var(--tw-border-opacity));
}
.hover\:border-gray-300:hover {