Skip to content

[WEB-4683] feat: popover component added to propel package#7607

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
feat-propel-popover-component
Aug 20, 2025
Merged

[WEB-4683] feat: popover component added to propel package#7607
sriramveeraghanta merged 1 commit intopreviewfrom
feat-propel-popover-component

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Aug 20, 2025

Description

This PR adds the Popover component to the Propel UI package.

Summary by CodeRabbit

  • New Features
    • Introduces a flexible Popover component with configurable placement and alignment, including auto and directional options.
    • Provides a compound API (Popover with Button/Trigger and Panel/Content) for intuitive composition.
    • Supports side offsets and container targeting to fine-tune positioning within custom containers.
    • Integrates portal and positioner behavior for proper layering and alignment across layouts.
    • Simplifies usage with a unified export, enabling straightforward imports.

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

coderabbitai bot commented Aug 20, 2025

Walkthrough

Adds a new popover module. Introduces a Popover compound component wrapping BasePopover with typed placement mapping and content/trigger wrappers. Exposes a barrel index re-exporting the popover root. Provides placement-to-side/align conversion, optional container targeting, and memoized components for trigger, portal, positioner, and content.

Changes

Cohort / File(s) Summary
Popover component implementation
packages/propel/src/popover/root.tsx
Adds Popover compound built on BasePopover. Exports: Placement type, PopoverContentProps, convertPlacementToSideAndAlign, Popover. Implements placement mapping, PopoverContent (Portal → Positioner → BasePopover.Popup), and wrapper components (Trigger, Portal, Positioner).
Popover barrel export
packages/propel/src/popover/index.ts
New barrel file re-exporting from ./root.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant TR as Popover.Trigger
  participant PR as Popover.Root
  participant CT as Popover.Content
  participant PT as Portal
  participant PS as Positioner
  participant PP as BasePopover.Popup

  U->>TR: click / focus
  TR->>PR: toggle open state
  alt open
    PR->>CT: render with props (placement | side/align)
    note over CT: placement → side/align via mapping
    CT->>PT: mount portal (optional containerRef)
    PT->>PS: position with finalSide/finalAlign, sideOffset
    PS->>PP: render popup content (children)
  else close
    PR-->>CT: unmount content
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my ears at portals bright,
A pop of over, soft in light—
Side and align, I map with glee,
From top to bottom, left to right, you see.
I hop, I place, I neatly land,
A panel blooms from button’s hand. 🐇✨

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.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-propel-popover-component

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 (7)
packages/propel/src/popover/root.tsx (6)

60-89: Forward the ref through PopoverContent (Panel) to BasePopover.Popup

Consumers won’t be able to attach a ref to Panel, and some focus-management/useImperativeHandle patterns will break. Wrap with forwardRef and pass it to BasePopover.Popup.

Apply this diff:

-// PopoverContent component
-const PopoverContent = React.memo<PopoverContentProps>(function PopoverContent({
-  children,
-  className,
-  placement,
-  side = "bottom",
-  align = "center",
-  sideOffset = 8,
-  containerRef,
-  ...props
-}) {
+// PopoverContent component
+type PopupElement = React.ElementRef<typeof BasePopover.Popup>;
+const PopoverContent = React.memo(
+  React.forwardRef<PopupElement, PopoverContentProps>(function PopoverContent(
+    {
+      children,
+      className,
+      placement,
+      side = "bottom",
+      align = "center",
+      sideOffset = 8,
+      containerRef,
+      ...props
+    },
+    ref
+  ) {
   // side and align calculations
   const { finalSide, finalAlign } = React.useMemo(() => {
     if (placement) {
       const converted = convertPlacementToSideAndAlign(placement);
       return { finalSide: converted.side, finalAlign: converted.align };
     }
     return { finalSide: side, finalAlign: align };
   }, [placement, side, align]);

   return (
     <PopoverPortal container={containerRef?.current}>
       <PopoverPositioner side={finalSide} sideOffset={sideOffset} align={finalAlign}>
-        <BasePopover.Popup data-slot="popover-content" className={className} {...props}>
+        <BasePopover.Popup ref={ref} data-slot="popover-content" className={className} {...props}>
           {children}
         </BasePopover.Popup>
       </PopoverPositioner>
     </PopoverPortal>
   );
-});
+})
+);

92-95: Consider forwarding refs on Trigger and Root for consistency

Forwarding refs on Trigger and Root improves composability (e.g., focusing the trigger, integrating with form libs). Optional but recommended for DS components.

Apply this diff:

-const PopoverTrigger = React.memo<React.ComponentProps<typeof BasePopover.Trigger>>(function PopoverTrigger(props) {
-  return <BasePopover.Trigger data-slot="popover-trigger" {...props} />;
-});
+const PopoverTrigger = React.memo(
+  React.forwardRef<
+    React.ElementRef<typeof BasePopover.Trigger>,
+    React.ComponentProps<typeof BasePopover.Trigger>
+  >(function PopoverTrigger(props, ref) {
+    return <BasePopover.Trigger ref={ref} data-slot="popover-trigger" {...props} />;
+  })
+);

-const Popover = Object.assign(
-  React.memo<React.ComponentProps<typeof BasePopover.Root>>(function Popover(props) {
-    return <BasePopover.Root data-slot="popover" {...props} />;
-  }),
+const Popover = Object.assign(
+  React.memo(
+    React.forwardRef<
+      React.ElementRef<typeof BasePopover.Root>,
+      React.ComponentProps<typeof BasePopover.Root>
+    >(function Popover(props, ref) {
+      return <BasePopover.Root ref={ref} data-slot="popover" {...props} />;
+    })
+  ),
   {
     Button: PopoverTrigger,
     Panel: PopoverContent,
   }
 );

Also applies to: 105-113


5-20: “auto/auto-start/auto-end” don’t behave as auto; they’re mapped to static bottom variants

Right now, specifying placement="auto" resolves to bottom/center, not an actual auto-position. This can be surprising to consumers.

Suggested options:

  • Implement true auto/fallback behavior if BasePopover.Positioner supports it (e.g., via middleware/flip/autoPlacement).
  • Or, remove auto/auto-start/auto-end from the public Placement union until supported.
  • At minimum, document that auto* currently map to bottom variants.

If you choose to remove auto*, here’s a minimal type clean-up:

 export type Placement =
-  | "auto"
-  | "auto-start"
-  | "auto-end"
   | "top-start"
   | "top-end"
   | "bottom-start"
   | "bottom-end"
   | "right-start"
   | "right-end"
   | "left-start"
   | "left-end"
   | "top"
   | "bottom"
   | "right"
   | "left";
@@
-  ["auto", { side: "bottom", align: "center" }],
-  ["auto-start", { side: "bottom", align: "start" }],
-  ["auto-end", { side: "bottom", align: "end" }],

I can help wire true auto placement if Positioner exposes the needed controls—confirm what’s available.

Also applies to: 34-50, 53-58


25-31: Prefer a direct container prop over containerRef for Portal

Passing a ref object only to derive current is awkward for consumers. Consider supporting container?: HTMLElement | null, and deriving from containerRef for back-compat.

Example change:

 export interface PopoverContentProps extends React.ComponentProps<typeof BasePopover.Popup> {
   placement?: Placement;
   align?: Align;
   sideOffset?: React.ComponentProps<typeof BasePopover.Positioner>["sideOffset"];
   side?: Side;
-  containerRef?: React.RefObject<HTMLElement>;
+  container?: HTMLElement | null;
+  containerRef?: React.RefObject<HTMLElement>; // deprecated: prefer `container`
 }
@@
-  containerRef,
+  container,
+  containerRef,
@@
-    <PopoverPortal container={containerRef?.current}>
+    <PopoverPortal container={container ?? containerRef?.current}>

If you’d like, I can follow up with a deprecation JSDoc on containerRef.

Also applies to: 80-88


72-79: useMemo here is unnecessary micro-optimization

The conversion is trivial; memoizing adds complexity and doesn’t buy much. Optional simplification:

Possible simplification:

  • Compute once without useMemo:
    • const converted = placement ? convertPlacementToSideAndAlign(placement) : { side, align };
    • const finalSide = converted.side; const finalAlign = converted.align;

122-122: Nit: spacing in named export

Align with common formatting.

-export { Popover};
+export { Popover };
packages/propel/src/popover/index.ts (1)

1-1: LGTM: Barrel re-export is straightforward

This re-exports the public API cleanly. Optionally, you could switch to explicit named exports for clearer treeshaking boundaries, but not required.

📜 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 1fccc0c.

📒 Files selected for processing (2)
  • packages/propel/src/popover/index.ts (1 hunks)
  • packages/propel/src/popover/root.tsx (1 hunks)
🔇 Additional comments (1)
packages/propel/src/popover/root.tsx (1)

116-121: Display names set — good for DevTools DX

Setting displayName on the components/wrappers helps debugging.

@sriramveeraghanta sriramveeraghanta merged commit 409ac30 into preview Aug 20, 2025
5 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat-propel-popover-component branch August 20, 2025 15:20
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