Skip to content

Comments

fix(toolbar): enable mouse wheel horizontal scroll#1246

Merged
Komzpa merged 2 commits intomainfrom
codex/fix-toolbar-horizontal-scroll-mouse-wheel-issue
Aug 27, 2025
Merged

fix(toolbar): enable mouse wheel horizontal scroll#1246
Komzpa merged 2 commits intomainfrom
codex/fix-toolbar-horizontal-scroll-mouse-wheel-issue

Conversation

@alesiahil
Copy link
Contributor

@alesiahil alesiahil commented Aug 14, 2025

Summary

  • allow mouse wheel to scroll toolbar horizontally
  • test toolbar mouse wheel scrolling

Testing

  • make precommit (fails: No rule to make target 'precommit')
  • pnpm lint
  • pnpm vitest run

https://kontur.fibery.io/Tasks/Task/21890


https://chatgpt.com/codex/tasks/task_e_689e29c8f218832fb45b1840f7116992

Summary by CodeRabbit

  • New Features
    • Toolbar content now supports horizontal scrolling using the vertical mouse wheel, improving navigation when controls overflow. This enhances usability on mice and trackpads without changing the visible layout.
  • Tests
    • Added automated tests to verify that vertical wheel input triggers horizontal scrolling in the toolbar, helping prevent regressions and ensuring consistent behavior across environments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Walkthrough

Adds a ref and test id to ToolbarContent to enable/use the wheel-to-horizontal scroll hook, and introduces a test verifying horizontal scrolling occurs on vertical wheel events via mocked dependencies.

Changes

Cohort / File(s) Summary
ToolbarContent component update
src/features/toolbar/components/ToolbarContent/ToolbarContent.tsx
Adds ref={scrollRef} and data-testid="toolbar-content" to the container so useWheelHorizontalScroll(scrollRef) operates on it; no API/signature changes.
ToolbarContent tests
src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx
New Vitest (Happy DOM) test verifying vertical wheel events cause horizontal scrolling. Mocks hooks/components/icons; dynamically imports component; asserts scrollLeft increases.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Browser
  participant ToolbarContent
  participant useWheelHorizontalScroll
  participant ContainerDiv

  User->>Browser: Wheel event (deltaY)
  Browser->>ContainerDiv: dispatch wheel
  ContainerDiv->>useWheelHorizontalScroll: event handled via ref
  useWheelHorizontalScroll->>ContainerDiv: set scrollLeft (> 0)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

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 codex/fix-toolbar-horizontal-scroll-mouse-wheel-issue

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.

@github-actions
Copy link

Language To Recheck Fuzzy Untranslated Total
ar 3 216 837 1056
be 0 41 0 41
de 2 216 837 1055
es 3 216 837 1056
id 2 216 837 1055
ko 3 216 837 1056
ru 0 24 0 24
uk 0 18 799 817
zh 0 43 0 43

@github-actions
Copy link

github-actions bot commented Aug 14, 2025

Bundle size diff

Old size New size Diff
5.07 MB 5.07 MB 33 B (0.00%)

@github-actions
Copy link

Preview environments for this PR:

These previews are automatically updated with each commit.

Note: After a new deployment, it may take a few minutes for the changes to propagate and for caches to update. During this time, you might experience temporary loading issues or see an older version of the app. If the app fails to load, please wait a few minutes and try again.

@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 13.15%. Comparing base (3fd0a65) to head (a1011f0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1246      +/-   ##
==========================================
+ Coverage   12.03%   13.15%   +1.12%     
==========================================
  Files         724      724              
  Lines       29798    29796       -2     
  Branches     1398     1387      -11     
==========================================
+ Hits         3585     3921     +336     
+ Misses      25657    25342     -315     
+ Partials      556      533      -23     
Components Coverage Δ
UI Components 0.78% <ø> (+0.48%) ⬆️
Core Logic 19.08% <ø> (+1.89%) ⬆️
Features 3.47% <100.00%> (+0.91%) ⬆️
Utilities 44.60% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link

codecov bot commented Aug 14, 2025

Bundle Report

Changes will increase total bundle size by 33 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
konturio/disaster-ninja-fe-esm 5.33MB 33 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: konturio/disaster-ninja-fe-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js 38 bytes 3.93kB 0.98%
assets/index-*.js -5 bytes 229.89kB -0.0%

Files in assets/index-*.js:

  • ./src/features/toolbar/components/ToolbarContent/ToolbarContent.tsx → Total Size: 590 bytes

@alesiahil alesiahil self-assigned this Aug 14, 2025
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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
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 settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd0a65 and a1011f0.

📒 Files selected for processing (2)
  • src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx (1 hunks)
  • src/features/toolbar/components/ToolbarContent/ToolbarContent.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx (1)
src/features/toolbar/components/ToolbarContent/ToolbarContent.tsx (1)
  • ToolbarContent (8-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: deploy
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/features/toolbar/components/ToolbarContent/ToolbarContent.tsx (1)

14-14: Good wiring: ref + hook correctly enable wheel-to-horizontal scroll.

The ref is attached to the correct container, and the hook is invoked with it. This should unlock horizontal scrolling as intended.

src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx (1)

8-20: Solid isolation via useToolbarContent mock.

The minimal mock for useToolbarContent keeps the test focused and deterministic.

Comment on lines 22 to 26
vi.mock('../ToolbarControl/ToolbarControl', () => ({
ToolbarControl: ({ id }: { id: string }) => (
<div data-testid={id} style={{ width: '300px' }} />
),
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove redundant inline width styling on mocked ToolbarControl.

You already force scrollable dimensions via scrollWidth/clientWidth. The inline width on the mock adds noise and could mislead future maintainers.

Apply this diff:

-  ToolbarControl: ({ id }: { id: string }) => (
-    <div data-testid={id} style={{ width: '300px' }} />
-  ),
+  ToolbarControl: ({ id }: { id: string }) => <div data-testid={id} />,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
vi.mock('../ToolbarControl/ToolbarControl', () => ({
ToolbarControl: ({ id }: { id: string }) => (
<div data-testid={id} style={{ width: '300px' }} />
),
}));
vi.mock('../ToolbarControl/ToolbarControl', () => ({
ToolbarControl: ({ id }: { id: string }) => <div data-testid={id} />,
}));
🤖 Prompt for AI Agents
In src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx around
lines 22 to 26, the mocked ToolbarControl includes an unnecessary inline style
width which is redundant because tests override scrollWidth/clientWidth; remove
the style attribute from the mock so it becomes simply <div data-testid={id} />
to avoid misleading future maintainers and let test-controlled dimensions drive
scrolling behavior.

Comment on lines 32 to 33
vi.mock('@konturio/default-icons', () => ({}));
vi.mock('@konturio/default-icons/tslib/index.js', () => ({}));
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm necessity of icon mocks; drop if unused.

If ToolbarContent + mocked ToolbarButton don’t transitively import @konturio/default-icons, these mocks can be removed to reduce test setup noise.

Run this to locate imports and confirm whether these mocks are actually hit in this test:


🏁 Script executed:

#!/bin/bash
# Check if ToolbarContent or its mocked children import the icons.
rg -n "@konturio/default-icons" -A 2 -B 2

Length of output: 20260


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- show test file ----"
sed -n '1,240p' src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx || true

echo
echo "---- show ToolbarContent component ----"
sed -n '1,240p' src/features/toolbar/components/ToolbarContent/ToolbarContent.tsx || true

echo
echo "---- show ToolbarIcon ----"
sed -n '1,240p' src/features/toolbar/components/ToolbarIcon.tsx || true

echo
echo "---- list files in toolbar/components ----"
ls -la src/features/toolbar/components || true

echo
echo "---- show ToolbarButton if exists ----"
sed -n '1,240p' src/features/toolbar/components/ToolbarButton.tsx || true || true

Length of output: 4246


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- locate useWheelHorizontalScroll ----"
rg -n "useWheelHorizontalScroll" || true

echo
echo "---- show hook file ----"
sed -n '1,240p' src/utils/hooks/useWheelHorizontalScroll.ts || sed -n '1,240p' src/utils/hooks/useWheelHorizontalScroll.tsx || true

echo
echo "---- list ToolbarControl files ----"
ls -la src/features/toolbar/components/ToolbarControl || true

echo
echo "---- show ToolbarControl implementation(s) ----"
sed -n '1,240p' src/features/toolbar/components/ToolbarControl/ToolbarControl.tsx || sed -n '1,240p' src/features/toolbar/components/ToolbarControl/index.tsx || true

echo
echo "---- list ToolbarButton files ----"
ls -la src/features/toolbar/components/ToolbarButton || true

echo
echo "---- show ToolbarButton implementation(s) ----"
sed -n '1,240p' src/features/toolbar/components/ToolbarButton/ToolbarButton.tsx || sed -n '1,240p' src/features/toolbar/components/ToolbarButton/index.tsx || true

Length of output: 6123


Remove unused @konturio/default-icons mocks from this test

The test already mocks ToolbarControl and ToolbarButton (and useToolbarContent), so importing ToolbarContent won't pull in ToolbarIcon/@konturio/default-icons — the two vi.mock calls are redundant and can be removed.

  • File to edit:
    • src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx — remove the two mock lines (currently lines 32–33)

Remove these lines:

vi.mock('@konturio/default-icons', () => ({}));
vi.mock('@konturio/default-icons/tslib/index.js', () => ({}));
🤖 Prompt for AI Agents
In src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx around
lines 32–33, remove the two redundant mock lines that import
@konturio/default-icons (vi.mock('@konturio/default-icons', () => ({})); and
vi.mock('@konturio/default-icons/tslib/index.js', () => ({}))); simply delete
those two lines so the test relies on the existing
ToolbarControl/ToolbarButton/useToolbarContent mocks.

Comment on lines 35 to 49
test('scrollLeft changes on vertical wheel events', async () => {
const { ToolbarContent } = await import('./ToolbarContent');
const { getByTestId } = render(<ToolbarContent />);
const scroll = getByTestId('toolbar-content');

Object.defineProperty(scroll, 'scrollWidth', { value: 300, configurable: true });
Object.defineProperty(scroll, 'clientWidth', { value: 100, configurable: true });

scroll.dispatchEvent(new WheelEvent('wheel', { deltaY: 50, bubbles: true }));

expect(
(scroll as HTMLDivElement).scrollLeft > 0,
`scrollLeft should change after wheel event, got ${(scroll as HTMLDivElement).scrollLeft}`,
).toBe(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Tighten assertions and make the wheel event cancelable.

  • Prefer toBeGreaterThan over boolean assertions for clarity.
  • Make the WheelEvent cancelable to align with typical implementations that call preventDefault.

Apply this diff:

-  scroll.dispatchEvent(new WheelEvent('wheel', { deltaY: 50, bubbles: true }));
+  scroll.dispatchEvent(new WheelEvent('wheel', { deltaY: 50, bubbles: true, cancelable: true }));
-
-  expect(
-    (scroll as HTMLDivElement).scrollLeft > 0,
-    `scrollLeft should change after wheel event, got ${(scroll as HTMLDivElement).scrollLeft}`,
-  ).toBe(true);
+  expect((scroll as HTMLDivElement).scrollLeft).toBeGreaterThan(0);

Optional follow-ups:

  • Add a precondition check to assert initial scrollLeft is 0, then assert it grows.
  • Add a complementary test asserting no scroll occurs when scrollWidth <= clientWidth.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('scrollLeft changes on vertical wheel events', async () => {
const { ToolbarContent } = await import('./ToolbarContent');
const { getByTestId } = render(<ToolbarContent />);
const scroll = getByTestId('toolbar-content');
Object.defineProperty(scroll, 'scrollWidth', { value: 300, configurable: true });
Object.defineProperty(scroll, 'clientWidth', { value: 100, configurable: true });
scroll.dispatchEvent(new WheelEvent('wheel', { deltaY: 50, bubbles: true }));
expect(
(scroll as HTMLDivElement).scrollLeft > 0,
`scrollLeft should change after wheel event, got ${(scroll as HTMLDivElement).scrollLeft}`,
).toBe(true);
});
test('scrollLeft changes on vertical wheel events', async () => {
const { ToolbarContent } = await import('./ToolbarContent');
const { getByTestId } = render(<ToolbarContent />);
const scroll = getByTestId('toolbar-content');
Object.defineProperty(scroll, 'scrollWidth', { value: 300, configurable: true });
Object.defineProperty(scroll, 'clientWidth', { value: 100, configurable: true });
scroll.dispatchEvent(new WheelEvent('wheel', { deltaY: 50, bubbles: true, cancelable: true }));
expect((scroll as HTMLDivElement).scrollLeft).toBeGreaterThan(0);
});
🤖 Prompt for AI Agents
In src/features/toolbar/components/ToolbarContent/ToolbarContent.test.tsx around
lines 35 to 49, tighten the assertion and make the simulated wheel event
cancelable: replace the boolean assertion that checks scrollLeft > 0 with an
explicit expect((scroll as HTMLDivElement).scrollLeft).toBeGreaterThan(0) to
provide clearer failure messages, and construct the WheelEvent with the
cancelable flag (e.g., new WheelEvent('wheel', { deltaY: 50, bubbles: true,
cancelable: true })) so it matches typical implementations that call
preventDefault.

@alesiahil
Copy link
Contributor Author

alesiahil commented Aug 14, 2025

Preview environments for this PR:

* Main App: https://konturio-disaster-ninja-fe-pr-1246-main.surge.sh

* Cosmos: https://konturio-disaster-ninja-fe-pr-1246-cosmos.surge.sh

These previews are automatically updated with each commit.

Note: After a new deployment, it may take a few minutes for the changes to propagate and for caches to update. During this time, you might experience temporary loading issues or see an older version of the app. If the app fails to load, please wait a few minutes and try again.

Checked on https://konturio-disaster-ninja-fe-pr-1246-main.surge.sh/map?map=2.096/0.000/0.000&feed=micglobal&layers=activeContributors%2CeventShape%2Ckontur_lines%2Cpopulation_density%2ChotProjects_outlines%2Cfocused-geometry&app=0b5b4047-3d9b-4ec4-993f-acf9c7315536 - working.

@Komzpa Komzpa merged commit 315aff8 into main Aug 27, 2025
8 of 9 checks passed
@Komzpa Komzpa deleted the codex/fix-toolbar-horizontal-scroll-mouse-wheel-issue branch August 27, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants