Skip to content

[WEB-4684] chore: dialog component enhancements#7606

Merged
sriramveeraghanta merged 8 commits intopreviewfrom
chore-dialog-component-enhancements
Aug 20, 2025
Merged

[WEB-4684] chore: dialog component enhancements#7606
sriramveeraghanta merged 8 commits intopreviewfrom
chore-dialog-component-enhancements

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Aug 20, 2025

Description

This PR includes following changes:

  • Enhancements to the Propel dialog component
  • Added z-index design tokens

Type of Change

  • Improvement
  • Code refactoring

Summary by CodeRabbit

  • New Features

    • Dialog supports width presets and configurable placement (center or top).
    • Compound API: use Dialog.Panel and Dialog.Title for composition.
  • Breaking Changes

    • DialogTrigger removed from the public API; Dialog is now a compound component.
  • Accessibility

    • Added ARIA attributes (role="dialog", aria-modal="true") for improved screen-reader support.
  • Style

    • Added a standardized z-index scale (modal, tooltip, backdrop, etc.) for consistent layering.

@anmolsinghbhatia anmolsinghbhatia self-assigned this Aug 20, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

Walkthrough

Removes dialog enums from constants, reimplements Dialog as a typed, memoized compound component (Dialog with Panel and Title) exposing width and position tokens and ARIA attributes, adds a named z-index scale to Tailwind config, and makes a formatting-only change in Popover positioning code.

Changes

Cohort / File(s) Summary of changes
Dialog constants removal
packages/propel/src/dialog/constants.ts
Deleted exported enums EDialogPosition and EDialogWidth.
Dialog component refactor & public API
packages/propel/src/dialog/root.tsx
Rewrote Dialog as a typed, memoized compound component exposing Dialog with static Panel and Title. Introduced public EDialogWidth tokens, DialogPosition (`"center"
Tailwind z-index scale
packages/tailwind-config/tailwind.config.js
Extended theme.extend with a named zIndex scale (base:0, header:10, sidebar:20, dropdown:30, popover:40, tooltip:50, sticky:60, backdrop:90, modal:100, toast:110, loader:120, max:9999).
Popover formatting
packages/propel/src/popover/root.tsx, packages/propel/src/popover/index.ts
Formatting-only: expanded React.memo wrapped PopoverPositioner into a multiline function and added trailing newline; no API or behavior changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User (renders)
  participant D as Dialog (Root)
  participant P as Dialog.Panel
  participant Port as Portal
  participant O as Overlay
  participant Pop as Popup (role="dialog")

  U->>D: Instantiate Dialog
  D->>P: Compose Panel (width, position props)
  P->>Port: Mount into Portal
  Port->>O: Render Overlay (OVERLAY_CLASSNAME)
  O->>Pop: Render Popup (BASE_CLASSNAME, role="dialog", aria-modal="true")
  Note over P,Pop: Class composition merges base + position + width tokens
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

🌐frontend, 🛠️refactor

Suggested reviewers

  • sriramveeraghanta
  • prateekshourya29
  • vamsikrishnamathala

Poem

I thump my paws — a portal swings,
Panels stacked with ribboned strings. 🥕
Overlay soft, a gentle veil,
Z-index lifts the evening pale.
I hop away — the UI trails.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f093479 and 6e0dd2d.

📒 Files selected for processing (1)
  • packages/propel/src/popover/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/propel/src/popover/index.ts
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-dialog-component-enhancements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@makeplane
Copy link

makeplane bot commented Aug 20, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
packages/propel/src/dialog/root.tsx (4)

22-37: Type simplicity: avoid redeclaring children where possible

You can simplify these props with PropsWithChildren instead of explicitly redeclaring children for each interface.

Example:

-export interface DialogProps extends React.ComponentProps<typeof BaseDialog.Root> {
-  children: React.ReactNode;
-}
+export type DialogProps = React.PropsWithChildren<
+  React.ComponentProps<typeof BaseDialog.Root>
+>;
 
-export interface DialogPanelProps extends React.ComponentProps<typeof BaseDialog.Popup> {
-  width?: EDialogWidth;
-  position?: DialogPosition;
-  children: React.ReactNode;
-}
+export type DialogPanelProps = React.PropsWithChildren<
+  React.ComponentProps<typeof BaseDialog.Popup>
+> & {
+  width?: EDialogWidth;
+  position?: DialogPosition;
+};
 
-export interface DialogTitleProps extends React.ComponentProps<typeof BaseDialog.Title> {
-  children: React.ReactNode;
-}
+export type DialogTitleProps = React.PropsWithChildren<
+  React.ComponentProps<typeof BaseDialog.Title>
+>;

40-42: Minor: avoid unnecessary cn invocation for static class list

OVERLAY_CLASSNAME is static; calling cn isn’t needed and adds runtime work (tiny, but avoidable).

Apply this diff:

-const OVERLAY_CLASSNAME = cn("fixed inset-0 z-backdrop bg-custom-backdrop");
+const OVERLAY_CLASSNAME = "fixed inset-0 z-backdrop bg-custom-backdrop";

77-98: Optional: the useMemo here is unnecessary

getPositionClassNames is a cheap, pure function; memoization doesn’t buy much and slightly complicates the code.

Apply this diff to compute directly:

-    const positionClassNames = React.useMemo(() => getPositionClassNames(position), [position]);
+    const positionClassNames = getPositionClassNames(position);

Optionally, consider exposing aria-labelledby on DialogPanelProps and wiring it to DialogTitle ids for stronger A11Y guarantees. Not blocking.


70-76: Remove unused internal DialogTrigger component

No exports or references to DialogTrigger were found anywhere in the repo. You can safely delete it to reduce bundle size and surface area:

  • File: packages/propel/src/dialog/root.tsx
  • Remove lines 70–76 (the DialogTrigger definition and its displayName)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a59ebad and 98e0568.

📒 Files selected for processing (3)
  • packages/propel/src/dialog/constants.ts (0 hunks)
  • packages/propel/src/dialog/root.tsx (1 hunks)
  • packages/tailwind-config/tailwind.config.js (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/propel/src/dialog/constants.ts
🧰 Additional context used
🪛 Biome (2.1.2)
packages/propel/src/dialog/root.tsx

[error] 44-44: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.

For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level

(lint/correctness/useHookAtTopLevel)

🪛 GitHub Check: Build and lint web apps
packages/propel/src/dialog/root.tsx

[failure] 44-44:
Unexpected block statement surrounding arrow body; move the returned value immediately after the =>

🪛 GitHub Actions: Build and lint web apps
packages/propel/src/dialog/root.tsx

[error] 44-44: ESLint (eslint . --max-warnings 7): Unexpected block statement surrounding arrow body; move the returned value immediately after the =>. (arrow-body-style)

🔇 Additional comments (3)
packages/tailwind-config/tailwind.config.js (1)

445-458: Z-index design tokens look solid and align with dialog layering needs

The scale is clear, non-overlapping, and maps well to the new z-backdrop and z-modal usages in the dialog. This should help avoid ad-hoc values going forward.

packages/propel/src/dialog/root.tsx (2)

9-20: Width tokens are well-chosen

The EDialogWidth values map cleanly to Tailwind’s max-w-* utilities and provide a sensible defaulting story (mobile w-full, wider screens constrained). No issues here.


58-62: Overlay composition and z-index choice look good

z-backdrop pairs correctly with z-modal, and the Backdrop and Popup ordering within the Portal is sound.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
packages/propel/src/dialog/root.tsx (1)

44-51: Fix: hook used at module scope (breaks lint) — convert to a plain function

React.useCallback cannot be used at module scope. This violates the hooks rule and is failing lint. It’s also unnecessary here—use a plain function with an expression body.

Apply this diff:

-const getPositionClassNames = React.useCallback(
-  (position: DialogPosition) =>
-    cn("isolate fixed z-modal", {
-      "top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2": position === "center",
-      "top-8 left-1/2 -translate-x-1/2": position === "top",
-    }),
-  []
-);
+const getPositionClassNames = (position: DialogPosition) =>
+  cn("isolate fixed z-modal", {
+    "top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2": position === "center",
+    "top-8 left-1/2 -translate-x-1/2": position === "top",
+  });
🧹 Nitpick comments (1)
packages/propel/src/dialog/root.tsx (1)

81-81: Simplify: drop useMemo; compute class once inline

getPositionClassNames(position) is pure and cheap; memoization adds complexity with no measurable gain.

Apply this diff:

-    const positionClassNames = React.useMemo(() => getPositionClassNames(position), [position]);
     return (
       <DialogPortal>
         <DialogOverlay />
         <BaseDialog.Popup
           ref={ref}
           data-slot="dialog-content"
-          className={cn(BASE_CLASSNAME, positionClassNames, width, className)}
+          className={cn(BASE_CLASSNAME, getPositionClassNames(position), width, className)}
           role="dialog"
           aria-modal="true"
           {...props}
         >

Also applies to: 88-88

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 98e0568 and d66bc5d.

📒 Files selected for processing (1)
  • packages/propel/src/dialog/root.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (2.1.2)
packages/propel/src/dialog/root.tsx

[error] 44-44: This hook is being called conditionally, but all hooks must be called in the exact same order in every component render.

For React to preserve state between calls, hooks needs to be called unconditionally and always in the same order.
See https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level

(lint/correctness/useHookAtTopLevel)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
packages/propel/src/dialog/root.tsx (6)

9-19: Width tokens mapping looks solid

Good coverage from sm:max-w-sm up to sm:max-w-7xl; sensible defaults for responsive dialog widths.


53-70: Portal/Overlay composition LGTM

Clear separation of responsibilities with memoized wrappers and data-slot tagging for testing/styling.


101-107: DialogTitle wrapper LGTM

Concise wrapper over BaseDialog.Title with sensible typography classes.


109-116: Typed compound component pattern is correct

Nice use of Object.assign with precise static property typing for Dialog.Panel and Dialog.Title.


40-41: zIndex tokens verified (backdrop < modal)
The Tailwind config (packages/tailwind-config/tailwind.config.js) defines:

  • backdrop: 90
  • modal: 100

Their ordering satisfies backdrop < modal. No further changes needed.


89-90: Keep ARIA attributes on Dialog.Popup

Base UI’s Dialog.Popup does not add role="dialog" or aria-modal by default—those attributes must be provided for proper accessibility. Including them here is correct and not redundant.

@sriramveeraghanta sriramveeraghanta merged commit 03479cf into preview Aug 20, 2025
6 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-dialog-component-enhancements branch August 20, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants