Skip to content

feat: BasePopper supports custom display area via css variables#169

Merged
hexqi merged 1 commit intoopentiny:developfrom
gene9831:feat/popper-custom-boundary
Jul 25, 2025
Merged

feat: BasePopper supports custom display area via css variables#169
hexqi merged 1 commit intoopentiny:developfrom
gene9831:feat/popper-custom-boundary

Conversation

@gene9831
Copy link
Copy Markdown
Collaborator

@gene9831 gene9831 commented Jul 23, 2025

BasePopper 支持通过 css 变量自定义显示区域。如果 BasePopper 设置了 prevent-overflow 属性,那么弹出框位置不会超出 viewpoint。在此基础上,增加了自定义显示区域的功能,让弹出框位置不会超出自定义的显示区域

新增如下 css 变量:

  • --tr-base-popper-min-top,默认值 0px
  • --tr-base-popper-max-bottom,默认值 100%
  • --tr-base-popper-min-left,默认值 0px
  • --tr-base-popper-max-right,默认值 100%

DropdownMenu 使用了基础的 BasePopper 组件。如果只需要配置 DropdownMenu 的自定义显示区域,设置如下 css 变量

  • --tr-dropdown-menu-min-top,默认值 0px
  • --tr-dropdown-menu-max-bottom,默认值 100%
  • --tr-dropdown-menu-min-left,默认值 0px
  • --tr-dropdown-menu-max-right,默认值 100%

以上的 css 变量都是 :root 范围的,如果只需要针对具体的元素自定义区域,增加 css 选择器优先级即可

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added configurable CSS variables for minimum and maximum top/left positioning of dropdown menus, allowing for more precise control over menu placement.
    • Dynamic calculation of dropdown menu boundaries based on the pills container's position in the suggestion pills demo.
  • Documentation

    • Updated documentation to describe new CSS variables for dropdown menu positioning and improved formatting for clarity.
  • Style

    • Enhanced dropdown and popper components to use only top/left positioning and support new CSS variable constraints for consistent alignment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 23, 2025

Walkthrough

The updates introduce new CSS variables for constraining dropdown and popper positioning, standardizing all popper placement to use only top and left properties. Logic was added to compute and pass container boundaries as CSS variables in the pills demo. Documentation was updated to reflect the new CSS variable options and formatting improvements.

Changes

File(s) Change Summary
docs/demos/suggestion/pills-popper.vue Added computed leftRange property to determine container bounds and pass as CSS variables to dropdown menus.
docs/src/components/dropdown-menu.md Updated documentation: improved formatting, added descriptions for new min/max top/left CSS variables.
packages/components/src/base-popper/index.vue Refactored popper positioning to use only top/left, added clamping via new CSS variables, updated internal logic.
packages/components/src/dropdown-menu/index.vue Added/inherited min/max top/left CSS variables for dropdown menu constraints, updated CSS only.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PillsPopper
    participant TrDropdownMenu
    participant BasePopper

    User->>PillsPopper: Interacts with pills
    PillsPopper->>PillsPopper: Compute leftRange (container bounds)
    PillsPopper->>TrDropdownMenu: Pass leftRange as CSS variables
    TrDropdownMenu->>BasePopper: Inherit CSS variables for min/max top/left
    BasePopper->>BasePopper: Clamp position using CSS variables
Loading

Estimated code review effort

3 (~45 minutes)

Poem

In the garden of menus, where poppers now roam,
Top and left guide their way—no more right, no more home.
CSS bounds keep them neat, in pixels they stay,
While docs grow more clear, showing the way.
A hop, a skip, a dropdown delight—
The rabbit approves: the layout feels right! 🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/demos/suggestion/pills-popper.vue

Oops! Something went wrong! :(

ESLint: 9.31.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:266:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:589:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:743:23)
at async /node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/eslint/eslint.js:767:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/eslint/eslint.js:764:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/cli.js:632:14)
at async main (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/bin/eslint.js:175:19)

packages/components/src/base-popper/index.vue

Oops! Something went wrong! :(

ESLint: 9.31.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:266:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:589:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:743:23)
at async /node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/eslint/eslint.js:767:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/eslint/eslint.js:764:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/cli.js:632:14)
at async main (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/bin/eslint.js:175:19)

packages/components/src/dropdown-menu/index.vue

Oops! Something went wrong! :(

ESLint: 9.31.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:266:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:589:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/config/config-loader.js:743:23)
at async /node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/eslint/eslint.js:767:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/eslint/eslint.js:764:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/lib/cli.js:632:14)
at async main (/node_modules/.pnpm/eslint@9.31.0/node_modules/eslint/bin/eslint.js:175:19)


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8e8894d and a62364c.

📒 Files selected for processing (4)
  • docs/demos/suggestion/pills-popper.vue (3 hunks)
  • docs/src/components/dropdown-menu.md (1 hunks)
  • packages/components/src/base-popper/index.vue (3 hunks)
  • packages/components/src/dropdown-menu/index.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/src/components/dropdown-menu.md
  • packages/components/src/base-popper/index.vue
  • packages/components/src/dropdown-menu/index.vue
  • docs/demos/suggestion/pills-popper.vue

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@gene9831 gene9831 force-pushed the feat/popper-custom-boundary branch from 8e8894d to a62364c Compare July 23, 2025 02:58
@hexqi hexqi merged commit 127ba81 into opentiny:develop Jul 25, 2025
@gene9831 gene9831 deleted the feat/popper-custom-boundary branch July 26, 2025 16:39
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.

2 participants