Skip to content

Fix duplicate highlighting in RComboBox dropdown by correcting hover detection#72

Closed
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-checkbox-highlight-error
Closed

Fix duplicate highlighting in RComboBox dropdown by correcting hover detection#72
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-checkbox-highlight-error

Conversation

Copy link

Copilot AI commented Jan 24, 2026

Summary

Fixed duplicate highlighting bug in RComboBox dropdown where multiple items would appear highlighted simultaneously.

Root Causes:

  1. Animation state variables persisted across dropdown open/close cycles
  2. Rendering condition order checked hover state before selected state, allowing hover colors to override selected item appearance
  3. Hover index calculation didn't account for dropdown border height, causing the first item to be incorrectly detected as hovered when cursor was in the border area

Solutions:

  1. Reset animation state (animatedIndex, previousAnimatedIndex, hoverProgress) in RComboBox_DropDown when dropdown opens
  2. Reordered OnDrawItem conditions to check isActuallySelected FIRST, ensuring selected items always show selected color
  3. Fixed hover index calculation by subtracting SystemInformation.BorderSize.Height from the Y position before dividing by item height
  4. Added guard to only calculate hover index when relativeY >= 0, preventing cursor in border area from triggering false hover detection

Result:

  • Selected items consistently display with selected color (orange background)
  • Only non-selected items can show hover effects when cursor is actually over them
  • No duplicate highlighting of multiple items
  • Accurate hover detection that accounts for dropdown borders and edge cases
  • Smooth animations between items without visual artifacts
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: 多选框存在重复的高亮</issue_title>
<issue_description>### Checklist

  • This bug has not already been reported (search here)
  • I have updated ContextMenuManager to the latest version
  • I understand that any issue not following the guidelines may be closed directly

Windows

Windows 11

Version

3.6.1.0

Steps to Reproduce

多选框的第一个项目似乎一直被高亮标注

Image

Crash logs

.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…on state on open

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix repeated highlight issue in checkbox selection Reset hover animation state on RComboBox dropdown open Jan 24, 2026
Copilot AI requested a review from Jack251970 January 24, 2026 18:58
@Jack251970
Copy link
Owner

@copilot It cannot work, if I drop one menu and the highlight item is the first one, and then I move my cursor to the second one. After that, the both items are still highlighted.

…vent duplicate highlighting

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 24, 2026

@copilot It cannot work, if I drop one menu and the highlight item is the first one, and then I move my cursor to the second one. After that, the both items are still highlighted.

Fixed in commit 25f660f. The issue was that the rendering logic checked hover state before selected state, allowing hover colors to override the selected item's appearance. Reordered the conditions to prioritize isActuallySelected first, ensuring selected items always display with selected color while only non-selected items can show hover effects.

@Jack251970
Copy link
Owner

@copilot It still cannot work. The highlight item will be more than one. Please resolve this

Copilot AI and others added 2 commits January 25, 2026 05:52
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 25, 2026

@copilot It still cannot work. The highlight item will be more than one. Please resolve this

Fixed in commits d283d95 and 5b47a9e. The root issue was that hover index calculation didn't account for the dropdown's border height. When the cursor was in the border area or near the top, it incorrectly calculated the first item as being hovered. Now the calculation subtracts SystemInformation.BorderSize.Height from the Y position and includes a guard to prevent negative values from triggering false hover detection.

Copilot AI changed the title Reset hover animation state on RComboBox dropdown open Fix duplicate highlighting in RComboBox dropdown by correcting hover detection Jan 25, 2026
@Jack251970 Jack251970 closed this Jan 25, 2026
@Jack251970 Jack251970 deleted the copilot/fix-checkbox-highlight-error branch January 25, 2026 05:54
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.

[Bug]: 多选框存在重复的高亮

2 participants