Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xranx OpenContext Custom Dialog

From Leeroopedia
Knowledge Sources
Domains UI, React
Last Updated 2026-10-24 00:00 GMT

Overview

Reusable dialog and context menu components for the desktop UI, providing alert, confirm, prompt, and right-click context menu functionality with i18n support.

Description

The Dialogs.jsx component module in src/ui/src/components/ exports two components: CustomDialog and ContextMenu. CustomDialog supports four types: alert, confirm, prompt, and prompt_multiline — each with optional destructive styling, i18n button labels, keyboard ESC handling, and auto-focus for prompt inputs. ContextMenu renders a positioned dropdown menu with icon+label items and click-outside dismissal.

Usage

Import these components in any UI component that needs modal dialogs or context menus.

Code Reference

Source Location

Signature

export function CustomDialog({
  isOpen, onClose, onCancel,
  type = 'alert', title, message, placeholder,
  initialValue = '', onConfirm,
  confirmText, cancelText, isDestructive = false
})

export function ContextMenu({ isOpen, x, y, onClose, items })

Import

import { CustomDialog, ContextMenu } from './components/Dialogs';

I/O Contract

Inputs (CustomDialog)

Name Type Required Description
isOpen boolean Yes Show/hide the dialog
type string No 'alert', 'confirm', 'prompt', 'prompt_multiline'
onConfirm Function Yes Called with input value (prompt) or undefined
isDestructive boolean No Red styling for destructive actions

Inputs (ContextMenu)

Name Type Required Description
isOpen boolean Yes Show/hide menu
x, y number Yes Screen position
items Array Yes [{ icon, label, onClick, className }]

Usage Examples

Confirm Dialog

import { CustomDialog } from './components/Dialogs';

const [showDelete, setShowDelete] = useState(false);

<CustomDialog
  isOpen={showDelete}
  type="confirm"
  title="Delete Document"
  message="Are you sure?"
  isDestructive
  onConfirm={() => handleDelete()}
  onClose={() => setShowDelete(false)}
/>

Context Menu

import { ContextMenu } from './components/Dialogs';

const [menu, setMenu] = useState({ open: false, x: 0, y: 0 });

<ContextMenu
  isOpen={menu.open}
  x={menu.x}
  y={menu.y}
  onClose={() => setMenu({ ...menu, open: false })}
  items={[
    { label: 'Rename', onClick: () => handleRename() },
    { label: 'Delete', onClick: () => handleDelete(), className: 'text-red-600' },
  ]}
/>

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment