Skip to content

Fix legend placement by selecting the correct bookmark icon - #435

Merged
haru merged 4 commits into
haru:developfrom
sk-ys:fix-bookmark-icon-selector
Sep 1, 2026
Merged

Fix legend placement by selecting the correct bookmark icon#435
haru merged 4 commits into
haru:developfrom
sk-ys:fix-bookmark-icon-selector

Conversation

@sk-ys

@sk-ys sk-ys commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR addresses an issue discovered in the implementation of PR #429.
The legend icon placement wasn't correct when one or more projects were bookmarked.

Problem

When one or more projects are bookmarked, the AI Helper legend icon would be appended to the first bookmark icon found, causing incorrect positioning.

Solution

Updated the selector logic to querySelectorAll():

Primary fix: Uses querySelectorAll('#content .icon-bookmarked-project') to get all bookmark icons and selects the last one with [length - 1], ensuring correct placement even with multiple bookmarked projects.

Preventive measure: #content scoping limits the search to the main content area, reducing the risk of selecting unintended elements.

- Updated to use querySelectorAll() to get all bookmark icons
- Select the last icon using array indexing [length - 1]
- Added #content scoping as a preventive measure to limit search scope
- This ensures the legend is positioned correctly when multiple bookmarks exist
- Addresses issue identified in PR haru#429 where multiple bookmark icons caused
  incorrect legend placement

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The selector change addresses a multi-bookmark regression but isn’t covered by a test that includes multiple .icon-bookmarked-project elements, and the test update introduces trailing whitespace that may fail linting.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes incorrect placement of the AI Helper legend item on projects#index when multiple .icon-bookmarked-project elements exist, by selecting the correct (last) bookmark icon in the main content area.

Changes:

  • Switch legend anchor lookup from querySelector() to querySelectorAll('#content .icon-bookmarked-project') and select the last match.
  • Update the JS DOM test setup to include a #content wrapper matching the new selector scope.
File summaries
File Description
assets/javascripts/project_legend/ai_helper_project_legend.js Selects the last bookmarked-project icon within #content before appending the AI Helper legend item.
test/javascript/project_legend/ai_helper_project_legend.test.js Adjusts DOM fixture to include #content so the selector works under test.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread assets/javascripts/project_legend/ai_helper_project_legend.js
Comment thread test/javascript/project_legend/ai_helper_project_legend.test.js
…ter match Redmine’s structure

- pass content container explicitly to test helpers
- model project hierarchy with an inner container for bookmark icon parent checks
- clarify selector limitation in legend script comments
@haru
haru merged commit 73ea90b into haru:develop Sep 1, 2026
43 checks passed
@haru

haru commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Thank you!

@sk-ys
sk-ys deleted the fix-bookmark-icon-selector branch September 2, 2026 10:46
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