fix: visual editor dialog and password reset flow
1. EmailBuilder: Fixed dialog handlers to not block all interactions - Previously dialog prevented all outside clicks - Now only blocks when WP media modal is open - Dialog can be properly closed via escape or outside click 2. DefaultTemplates: Updated new_customer email - Added note about using 'Forgot Password?' if link expires - Clear instructions for users
This commit is contained in:
@@ -80,7 +80,7 @@ export function EmailBuilder({ blocks, onChange, variables = [] }: EmailBuilderP
|
||||
throw new Error(`Unknown block type: ${type}`);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
onChange([...blocks, newBlock]);
|
||||
};
|
||||
|
||||
@@ -91,10 +91,10 @@ export function EmailBuilder({ blocks, onChange, variables = [] }: EmailBuilderP
|
||||
const moveBlock = (id: string, direction: 'up' | 'down') => {
|
||||
const index = blocks.findIndex(b => b.id === id);
|
||||
if (index === -1) return;
|
||||
|
||||
|
||||
const newIndex = direction === 'up' ? index - 1 : index + 1;
|
||||
if (newIndex < 0 || newIndex >= blocks.length) return;
|
||||
|
||||
|
||||
const newBlocks = [...blocks];
|
||||
[newBlocks[index], newBlocks[newIndex]] = [newBlocks[newIndex], newBlocks[index]];
|
||||
onChange(newBlocks);
|
||||
@@ -102,7 +102,7 @@ export function EmailBuilder({ blocks, onChange, variables = [] }: EmailBuilderP
|
||||
|
||||
const openEditDialog = (block: EmailBlock) => {
|
||||
setEditingBlockId(block.id);
|
||||
|
||||
|
||||
if (block.type === 'card') {
|
||||
// Convert markdown to HTML for rich text editor
|
||||
const htmlContent = parseMarkdownBasics(block.content);
|
||||
@@ -121,16 +121,16 @@ export function EmailBuilder({ blocks, onChange, variables = [] }: EmailBuilderP
|
||||
setEditingCustomMaxWidth(block.customMaxWidth);
|
||||
setEditingAlign(block.align);
|
||||
}
|
||||
|
||||
|
||||
setEditDialogOpen(true);
|
||||
};
|
||||
|
||||
const saveEdit = () => {
|
||||
if (!editingBlockId) return;
|
||||
|
||||
|
||||
const newBlocks = blocks.map(block => {
|
||||
if (block.id !== editingBlockId) return block;
|
||||
|
||||
|
||||
if (block.type === 'card') {
|
||||
// Convert HTML from rich text editor back to markdown for storage
|
||||
const markdownContent = htmlToMarkdown(editingContent);
|
||||
@@ -154,10 +154,10 @@ export function EmailBuilder({ blocks, onChange, variables = [] }: EmailBuilderP
|
||||
align: editingAlign,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return block;
|
||||
});
|
||||
|
||||
|
||||
onChange(newBlocks);
|
||||
setEditDialogOpen(false);
|
||||
setEditingBlockId(null);
|
||||
@@ -269,29 +269,23 @@ export function EmailBuilder({ blocks, onChange, variables = [] }: EmailBuilderP
|
||||
|
||||
{/* Edit Dialog */}
|
||||
<Dialog open={editDialogOpen} onOpenChange={setEditDialogOpen}>
|
||||
<DialogContent
|
||||
className="sm:max-w-2xl"
|
||||
<DialogContent
|
||||
className="sm:max-w-2xl max-h-[90vh] overflow-y-auto"
|
||||
onInteractOutside={(e) => {
|
||||
// Check if WordPress media modal is currently open
|
||||
// Only prevent closing if WordPress media modal is open
|
||||
const wpMediaOpen = document.querySelector('.media-modal');
|
||||
|
||||
if (wpMediaOpen) {
|
||||
// If WP media is open, ALWAYS prevent dialog from closing
|
||||
// regardless of where the click happened
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// If WP media is not open, prevent closing dialog for outside clicks
|
||||
e.preventDefault();
|
||||
// Otherwise, allow the dialog to close normally via outside click
|
||||
}}
|
||||
onEscapeKeyDown={(e) => {
|
||||
// Allow escape to close WP media modal
|
||||
// Only prevent escape if WP media modal is open
|
||||
const wpMediaOpen = document.querySelector('.media-modal');
|
||||
if (wpMediaOpen) {
|
||||
return;
|
||||
e.preventDefault();
|
||||
}
|
||||
e.preventDefault();
|
||||
// Otherwise, allow escape to close dialog
|
||||
}}
|
||||
>
|
||||
<DialogHeader>
|
||||
|
||||
Reference in New Issue
Block a user