Context
The Dialog component is a modal overlay designed to render the page inert while it is open. This ensures that users focus solely on the dialog content, blocking interaction with the underlying page until the dialog is dismissed. The Popover component should be used instead for non-blocking overlays or tooltips.
Problem
Dialogs are critical for capturing user attention and input, but their implementation can vary widely, leading to inconsistencies in how dialogs are managed, structured, and interacted with across different parts of the application.
Proposed Solution
Dialog Implementation:
- Use the isOpen prop to control the visibility of the dialog.
- Handle user interactions and dismissals through the onClose callback.
- The dialog should include customizable slots for a title, main content, and action buttons to ensure a consistent and structured layout.
When to use:
- The Dialog component is ideal for scenarios requiring the user’s full attention, for example, presenting critical information, seeking confirmation, or requiring a decision before proceeding with an action.
- Common use cases include confirming destructive actions (e.g., deleting data) or gathering essential user inputs.
- Since the Dialog blocks interaction with the rest of the page, it should be reserved for situations where user input is crucial before continuing. For less disruptive interactions, such as providing additional options or contextual information, use a Popover instead, which allows users to access and dismiss content while continuing to interact with the page.
Initial proposed props:
- isOpen: Controls whether the dialog is visible.
- onClose: Function to close the dialog.
- title: Content for the dialog’s title.
- content: Main content of the dialog, such as text or forms.
- actions: Action buttons or other controls, like "Confirm" and "Cancel" buttons.
Decisions to Be Finalized
- Custom Actions vs. Predefined Templates:
- Custom Actions:
- Offers greater flexibility by allowing any custom child components for action buttons, accommodating more complex controls tailored to specific needs.
- Predefined Action Templates:
- Simplifies implementation by offering commonly used actions like "Delete" or "Save" out-of-the-box, ensuring consistency and reducing development time. This approach standardizes interactions but may limit flexibility.
- Adding a Hook:
- Consider adding a hook to handle the Dialog's state, encapsulating common patterns for opening, closing, and managing interactions. This hook would simplify the integration of dialog functionality, allowing developers to manage state and side effects easily within their components.
- Chameleon:
- ❓ How do Dialogs and Chameleon intersect
Next Steps
- Review and Feedback: Gather input on whether to prioritize custom actions or predefined templates and finalize the decision on adding a hook for state management.
- Implementation: Once decisions are finalized, implement the Dialog component with the agreed-upon props and structure, ensuring consistent usage across the application.
This decision ensures that the Dialog component is implemented consistently, providing a reliable and user-friendly way to capture critical user input while maintaining a clear and focused user experience.