Skip to content

fix(color-picker): auto flip#4187

Merged
zzcr merged 2 commits into
opentiny:devfrom
GaoNeng-wWw:feat/color-picker-auto-flip
May 11, 2026
Merged

fix(color-picker): auto flip#4187
zzcr merged 2 commits into
opentiny:devfrom
GaoNeng-wWw:feat/color-picker-auto-flip

Conversation

@GaoNeng-wWw

@GaoNeng-wWw GaoNeng-wWw commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #4058

What is the new behavior?

1

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

#4088

很长时间没有更新,所以就开了这个PR

Summary by CodeRabbit

  • Refactor

    • Reworked color picker dropdown to use a popover-based wrapper for more stable positioning and consistent interaction.
  • Style

    • Adjusted popper and panel styling to remove extra spacing and enforce transparent background for the dropdown.
  • Chores

    • Added a popover dependency for the color picker package.
  • Tests

    • Updated demo test selectors to be less specific for more robust interactions.

@github-actions github-actions Bot added the bug Something isn't working label Apr 17, 2026
@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0c6cfb2e-0733-4464-9cd1-7e00368ce340

📥 Commits

Reviewing files that changed from the base of the PR and between a168691 and 82aef86.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/color-picker/linear-gradient.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • examples/sites/demos/pc/app/color-picker/linear-gradient.spec.ts

Walkthrough

Refactors the color picker to use a Popover component (manual trigger) instead of a Transition wrapper, updates component markup and panel sizing, adds a popover dependency, and adjusts Less styles for popper/panel positioning and appearance.

Changes

Cohort / File(s) Summary
Popover Integration
packages/vue/src/color-picker/package.json, packages/vue/src/color-picker/src/pc.vue
Added @opentiny/vue-popover dependency; replaced Transition wrapper with <tiny-popover> using v-model="state.isShow" and trigger="manual". Moved trigger into #reference slot and changed panel sizing from min-width: 330px to width: 330px.
Theme Styling Updates
packages/theme/src/color-picker/index.less, packages/theme/src/color-select-panel/index.less
Added &__popper rule forcing padding: 0 !important; background: transparent !important; changed .color-select-panel from position: absolute to position: relative and removed margin-top: 8px.
Tests / Examples
examples/sites/demos/pc/app/color-picker/linear-gradient.spec.ts
Relaxed Playwright selectors by removing direct-child combinators (>) to target elements anywhere within their parent selectors.

Sequence Diagram

sequenceDiagram
    actor User
    participant CP as ColorPicker (pc.vue)
    participant PO as Popover (tiny-popover)
    participant CSP as ColorSelectPanel

    User->>CP: Click trigger
    CP->>CP: set state.isShow = true
    CP->>PO: v-model update (show)
    PO->>PO: compute popper position
    PO->>CSP: mount/render panel (width: 330px)
    CSP->>User: display panel

    User->>CSP: choose color
    CSP->>CP: emit color value
    CP->>CP: set state.isShow = false
    CP->>PO: v-model update (hide)
    PO->>User: close popover
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped from Transition to a popover nest,
Where panels sit tidy and colors rest,
A nudge, a click — the palette appears,
I nibble the pixels and giggle with cheers! 🎨🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix(color-picker): auto flip' is vague and generic; it does not clearly specify what aspect of the color picker is being fixed or what 'auto flip' means in this context. Provide a more descriptive title that explains the specific fix, such as 'fix(color-picker): add auto-flip behavior for dropdown positioning' or similar to clarify the change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
packages/vue/src/color-picker/package.json (1)

12-12: LGTM — dependency addition is correct.

@opentiny/vue-popover exists at the same workspace version (3.30.0) and exports a default component, matching the new import TinyPopover from '@opentiny/vue-popover' in pc.vue.

Minor nit: other dependencies here use workspace:~ while this one uses workspace:^. Consider aligning to workspace:~ for consistency with the rest of the block.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue/src/color-picker/package.json` at line 12, The dependency entry
for "@opentiny/vue-popover" in package.json uses "workspace:^" which is
inconsistent with the other dependencies that use "workspace:~"; update the
version specifier for "@opentiny/vue-popover" to "workspace:~" to match the
project's dependency style (this affects the package.json dependency entry
referencing "@opentiny/vue-popover" and is referenced by the import TinyPopover
in pc.vue).
packages/vue/src/color-picker/src/pc.vue (1)

38-40: Remove commented-out <Transition> block.

Leftover dead code from the previous implementation — the popover now owns the enter/leave transition. Please delete rather than leaving it commented.

🧹 Proposed cleanup
-      <!-- <Transition name="tiny-zoom-in-top">
-        
-      </Transition> -->
     </tiny-popover>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue/src/color-picker/src/pc.vue` around lines 38 - 40, Remove the
leftover commented-out <Transition> block in pc.vue: delete the entire commented
section <!-- <Transition name="tiny-zoom-in-top"> ... </Transition> --> so the
file no longer contains dead commented transition code (the popover now manages
transitions). Ensure no remaining commented Transition lines remain in pc.vue
and run formatting/linting to keep the file tidy.
packages/theme/src/color-picker/index.less (1)

54-57: Prefer specificity over !important where possible.

Both declarations use !important to override the default .tiny-popover styling. Since popperClass is applied on the same element as .tiny-popover (see packages/vue/src/popover/src/pc.vue line ~6), a selector like &.@{color-picker-prefix-cls}__popper combined with the parent popover class, or simply relying on source-order cascade with equal specificity, is usually enough. !important makes future overrides (e.g. user theming) harder.

Not a blocker — consider as a follow-up cleanup.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/theme/src/color-picker/index.less` around lines 54 - 57, Replace the
two !important overrides in the color picker popper rule by increasing selector
specificity instead: target the same element that gets both the popperClass and
.tiny-popover (e.g., combine the popper parent/popover class with &__popper or
use &.@{color-picker-prefix-cls}__popper) so padding:0 and
background:transparent win via specificity or source order rather than using
!important; update the selector where &__popper is defined (color-picker's LESS)
and remove the !important flags.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/theme/src/color-picker/index.less`:
- Around line 54-57: Replace the two !important overrides in the color picker
popper rule by increasing selector specificity instead: target the same element
that gets both the popperClass and .tiny-popover (e.g., combine the popper
parent/popover class with &__popper or use &.@{color-picker-prefix-cls}__popper)
so padding:0 and background:transparent win via specificity or source order
rather than using !important; update the selector where &__popper is defined
(color-picker's LESS) and remove the !important flags.

In `@packages/vue/src/color-picker/package.json`:
- Line 12: The dependency entry for "@opentiny/vue-popover" in package.json uses
"workspace:^" which is inconsistent with the other dependencies that use
"workspace:~"; update the version specifier for "@opentiny/vue-popover" to
"workspace:~" to match the project's dependency style (this affects the
package.json dependency entry referencing "@opentiny/vue-popover" and is
referenced by the import TinyPopover in pc.vue).

In `@packages/vue/src/color-picker/src/pc.vue`:
- Around line 38-40: Remove the leftover commented-out <Transition> block in
pc.vue: delete the entire commented section <!-- <Transition
name="tiny-zoom-in-top"> ... </Transition> --> so the file no longer contains
dead commented transition code (the popover now manages transitions). Ensure no
remaining commented Transition lines remain in pc.vue and run formatting/linting
to keep the file tidy.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2a6d27f2-8671-4d85-93cb-f8266cd45648

📥 Commits

Reviewing files that changed from the base of the PR and between c1e703b and a168691.

📒 Files selected for processing (4)
  • packages/theme/src/color-picker/index.less
  • packages/theme/src/color-select-panel/index.less
  • packages/vue/src/color-picker/package.json
  • packages/vue/src/color-picker/src/pc.vue
💤 Files with no reviewable changes (1)
  • packages/theme/src/color-select-panel/index.less

@zzcr zzcr merged commit f75adb3 into opentiny:dev May 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants