Skip to content

Feature/matb/fix floor selector expansion on small screens#669

Merged
matbmapspeople merged 11 commits intomainfrom
feature/matb/fix_floor_selector_expansion_on_small_screens
Mar 27, 2026
Merged

Feature/matb/fix floor selector expansion on small screens#669
matbmapspeople merged 11 commits intomainfrom
feature/matb/fix_floor_selector_expansion_on_small_screens

Conversation

@matbmapspeople
Copy link
Copy Markdown
Collaborator

@matbmapspeople matbmapspeople commented Mar 27, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a layout overlap so the expanded floor selector no longer covers bottom-right map controls; those controls hide and become non-interactive while the selector is open, and overlap is recalculated on resize, orientation changes, and after layout updates.
    • Respect configured minimum zoom when provided, avoiding previous forced override.
  • Chores
    • Updated the changelog for the release.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Detects when the Floor Selector opens and visually overlaps desktop bottom-right controls; observes DOM changes, measures bounding rectangles, and conditionally hides/disables the bottom-right controls while the selector is expanded.

Changes

Cohort / File(s) Summary
MapControls component
packages/map-template/src/components/MIMap/MapControls/MapControls.jsx
Added isFloorSelectorExpanded state and bottomControlsRef, measureOverlap callback, integrated useFloorSelectorToggleObserver, added resize/orientation measurement effect, and conditionally apply map-controls-container--floor-selector-open on desktop bottom-right controls.
Styles
packages/map-template/src/components/MIMap/MapControls/MapControls.scss
Added .map-controls-container--floor-selector-open to hide and disable pointer events for bottom-right controls when the floor selector overlaps.
New hook
packages/map-template/src/hooks/useFloorSelectorToggleObserver.js
New useFloorSelectorToggleObserver hook uses a MutationObserver to detect floor selector open/close, returns isFloorSelectorOpenRef, calls setIsFloorSelectorExpanded, and schedules measureOverlap with cleanup.
MapTemplate change
packages/map-template/src/components/MapTemplate/MapTemplate.jsx
minZoom calculation now prefers appConfig.appSettings.minZoom when provided, removing previous ignoreViewportBounds-based override.
Changelog
packages/map-template/CHANGELOG.md
Added v1.96.20 entry documenting the Floor Selector overlap fix and the new hook/wiring.

Sequence Diagram(s)

sequenceDiagram
  participant FloorSelector as Floor Selector
  participant Hook as useFloorSelectorToggleObserver
  participant MapControls as MapControls
  participant Browser as Browser (resize/orientation)

  FloorSelector->>Hook: DOM mutation (class change)
  Hook->>Hook: detect .mi-floor-selector__button--open
  Hook-->>MapControls: setIsFloorSelectorExpanded(true) and schedule measureOverlap
  MapControls->>MapControls: measureOverlap (read bounding rects of floorSelectorRef & bottomControlsRef)
  alt overlap detected
    MapControls->>MapControls: setIsFloorSelectorExpanded(true)
    MapControls->>MapControls: add class map-controls-container--floor-selector-open
  else no overlap
    MapControls->>MapControls: setIsFloorSelectorExpanded(false)
    MapControls->>MapControls: remove class
  end
  Browser->>MapControls: resize / orientationchange
  MapControls->>MapControls: re-run measureOverlap if selector open
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Lucaci-Andrei

Poem

"🐰 I hopped upon the map so wide,
and watched a selector swell with pride.
When floors expand and buttons meet,
I hide the controls to keep things neat.
A tiny hop, a tidy view — hooray! 🥕"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feature/matb/fix floor selector expansion on small screens' directly describes the main change: fixing floor selector expansion behavior on small screens, which is the core issue addressed across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/matb/fix_floor_selector_expansion_on_small_screens

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.

… expanded Floor Selector and Zoom Controls/Full Screen button
Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/map-template/src/components/MIMap/MapControls/MapControls.jsx`:
- Around line 218-266: The effect that measures overlap (useEffect using
floorSelectorRef, bottomControlsRef, overlapTimerRef, MutationObserver, and
setIsFloorSelectorExpanded) only listens for class mutations and only reruns for
mapsIndoorsInstance/mapInstance; update it to also recompute on viewport/layout
changes by adding window 'resize' and 'orientationchange' listeners (and
visualViewport 'resize' if available) that call the existing checkOverlap
function, run checkOverlap once on mount to seed state, include isDesktop and
isKiosk in the effect dependency array so layout-mode transitions retrigger the
effect, and ensure all added listeners and overlapTimerRef timeouts are removed
in the cleanup along with observer.disconnect().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: acca17cc-99b2-4068-b19f-4d2ffe5c1862

📥 Commits

Reviewing files that changed from the base of the PR and between 0f698ad and 8e96fa5.

📒 Files selected for processing (2)
  • packages/map-template/src/components/MIMap/MapControls/MapControls.jsx
  • packages/map-template/src/components/MIMap/MapControls/MapControls.scss

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/map-template/CHANGELOG.md`:
- Line 12: Change the typo in the changelog entry by replacing the truncated
word "butto" with the correct word "button" in the line that reads 'An issue
when expanded Floor Selector would overlap Zoom Controls and Full Screen
butto.'; ensure the corrected sentence reads 'An issue when expanded Floor
Selector would overlap Zoom Controls and Full Screen button.' and keep
punctuation and capitalization consistent with the surrounding entries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 45507146-a744-430f-b792-aa1ad2b658a7

📥 Commits

Reviewing files that changed from the base of the PR and between 8e96fa5 and faba81f.

📒 Files selected for processing (1)
  • packages/map-template/CHANGELOG.md

…responsiveness. Added a measureOverlap function to handle overlap checks and updated the observer for class changes. Adjusted event listeners for viewport changes to ensure accurate overlap measurement when the floor selector is open.
…le observation, improving overlap detection and code organization. The new useFloorSelectorToggleObserver hook encapsulates the logic for monitoring the floor selector's state and measuring overlap with bottom controls.
Copy link
Copy Markdown
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.

🧹 Nitpick comments (2)
packages/map-template/src/hooks/useFloorSelectorToggleObserver.js (2)

28-29: Consider resetting state when button element is not found.

If the button element is not found (line 29 early return), the isFloorSelectorOpenRef retains its previous value and setIsFloorSelectorExpanded is not called, potentially leaving stale state. This could happen if the floor selector is removed from DOM while open.

♻️ Proposed fix
             const button = floorSelector.querySelector('.mi-floor-selector__button');
-            if (!button) return;
+            if (!button) {
+                isFloorSelectorOpenRef.current = false;
+                setIsFloorSelectorExpanded(false);
+                return;
+            }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/map-template/src/hooks/useFloorSelectorToggleObserver.js` around
lines 28 - 29, When the queried button (const button =
floorSelector.querySelector('.mi-floor-selector__button')) is missing and the
function currently returns early, reset the component state to avoid stale
values: set isFloorSelectorOpenRef.current = false and call
setIsFloorSelectorExpanded(false) before returning so the ref and UI state are
cleared; also ensure any related cleanup (e.g., disconnecting observers) still
runs if applicable.

39-39: Magic number for animation delay.

The 50ms delay assumes the floor selector expansion animation completes within this time. Consider extracting this to a named constant or documenting the assumption. If the animation duration changes in the future (in packages/components/src/components/floor-selector/floor-selector.tsx), this value may need adjustment.

♻️ Proposed fix
+// Delay to allow floor selector expansion animation to complete before measuring overlap
+const ANIMATION_SETTLE_DELAY_MS = 50;
+
 export function useFloorSelectorToggleObserver({ floorSelectorRef, setIsFloorSelectorExpanded, measureOverlap, mapsIndoorsInstance, mapInstance }) {
     const overlapTimerRef = useRef(null);
     const isFloorSelectorOpenRef = useRef(false);
     // ... later in onClassChange:
-            overlapTimerRef.current = setTimeout(measureOverlap, 50);
+            overlapTimerRef.current = setTimeout(measureOverlap, ANIMATION_SETTLE_DELAY_MS);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/map-template/src/hooks/useFloorSelectorToggleObserver.js` at line
39, The hard-coded 50ms delay in useFloorSelectorToggleObserver
(overlapTimerRef.current = setTimeout(measureOverlap, 50)) is a magic number
tied to the floor selector animation; extract this into a named constant (e.g.,
FLOOR_SELECTOR_ANIMATION_DELAY or FLOOR_SELECTOR_MEASURE_DELAY) near the top of
useFloorSelectorToggleObserver and replace the literal 50 with that constant,
and/or read the duration from a shared constant or prop defined in the
floor-selector component (floor-selector.tsx) so changes to the component
animation duration stay in sync; update any comments to document the assumption
and reference measureOverlap and overlapTimerRef so future maintainers know
where to adjust the delay.
🤖 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/map-template/src/hooks/useFloorSelectorToggleObserver.js`:
- Around line 28-29: When the queried button (const button =
floorSelector.querySelector('.mi-floor-selector__button')) is missing and the
function currently returns early, reset the component state to avoid stale
values: set isFloorSelectorOpenRef.current = false and call
setIsFloorSelectorExpanded(false) before returning so the ref and UI state are
cleared; also ensure any related cleanup (e.g., disconnecting observers) still
runs if applicable.
- Line 39: The hard-coded 50ms delay in useFloorSelectorToggleObserver
(overlapTimerRef.current = setTimeout(measureOverlap, 50)) is a magic number
tied to the floor selector animation; extract this into a named constant (e.g.,
FLOOR_SELECTOR_ANIMATION_DELAY or FLOOR_SELECTOR_MEASURE_DELAY) near the top of
useFloorSelectorToggleObserver and replace the literal 50 with that constant,
and/or read the duration from a shared constant or prop defined in the
floor-selector component (floor-selector.tsx) so changes to the component
animation duration stay in sync; update any comments to document the assumption
and reference measureOverlap and overlapTimerRef so future maintainers know
where to adjust the delay.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 091cba14-d5be-4f17-80de-0ef1145b0615

📥 Commits

Reviewing files that changed from the base of the PR and between faba81f and dda22db.

📒 Files selected for processing (3)
  • packages/map-template/CHANGELOG.md
  • packages/map-template/src/components/MIMap/MapControls/MapControls.jsx
  • packages/map-template/src/hooks/useFloorSelectorToggleObserver.js

…server` and its integration in MapControls for improved floor selector functionality.
Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
packages/map-template/CHANGELOG.md (1)

12-14: Consider restructuring to clarify the fix vs. implementation.

While the information requested by the reviewer has been added, the current structure lists implementation details (lines 13-14) as separate bullet points under "Fixed," which typically describes user-facing issues. Consider integrating these details into the first bullet for better clarity:

📝 Suggested restructuring
-- An issue when expanded Floor Selector would overlap Zoom Controls and Full Screen button.
-- Added a new custom hook `useFloorSelectorToggleObserver.js`.
-- Added newly created observer to MapControls.jsx
+- An issue when expanded Floor Selector would overlap Zoom Controls and Full Screen button. Resolved by introducing a custom hook (`useFloorSelectorToggleObserver.js`) and integrating it into `MapControls.jsx` to detect overlap and conditionally hide controls.

This preserves all the technical details while making it clear they're part of the implementation of the fix, not separate fixes themselves.

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

In `@packages/map-template/CHANGELOG.md` around lines 12 - 14, Update the
CHANGELOG.md "Fixed" section so the user-facing fix and its implementation
details are combined into a single bullet: mention the overlap bug ("expanded
Floor Selector would overlap Zoom Controls and Full Screen button") and append
the implementation notes that you added the custom hook
useFloorSelectorToggleObserver.js and wired it into MapControls.jsx as the
mechanism that resolves the issue, rather than listing those as separate
bullets; keep the wording concise and clearly indicate they are part of the same
fix.
🤖 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/map-template/CHANGELOG.md`:
- Around line 12-14: Update the CHANGELOG.md "Fixed" section so the user-facing
fix and its implementation details are combined into a single bullet: mention
the overlap bug ("expanded Floor Selector would overlap Zoom Controls and Full
Screen button") and append the implementation notes that you added the custom
hook useFloorSelectorToggleObserver.js and wired it into MapControls.jsx as the
mechanism that resolves the issue, rather than listing those as separate
bullets; keep the wording concise and clearly indicate they are part of the same
fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef6f1988-a63b-4cec-b6c8-41db8af4ad53

📥 Commits

Reviewing files that changed from the base of the PR and between dda22db and 554e118.

📒 Files selected for processing (1)
  • packages/map-template/CHANGELOG.md

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/map-template/src/components/MapTemplate/MapTemplate.jsx`:
- Around line 526-527: The inline comment referencing ignoreViewportBounds is
stale—either remove it or restore its behavior; update the comment near the
minZoom assignment (the minZoom: appConfig?.appSettings?.minZoom ??
ZoomLevelValues.minZoom line) to reflect current behavior (no mention of
ignoreViewportBounds) or reintroduce logic that checks an ignoreViewportBounds
flag and sets minZoom to ZoomLevelValues.minZoom when true; locate the minZoom
assignment in MapTemplate.jsx and either delete/replace the comment or implement
the ignoreViewportBounds check around minZoom to match intended functionality.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 031d67d6-5ca5-40cc-9053-a5d9557e720a

📥 Commits

Reviewing files that changed from the base of the PR and between 554e118 and 66d88cb.

📒 Files selected for processing (1)
  • packages/map-template/src/components/MapTemplate/MapTemplate.jsx

@Lucaci-Andrei Lucaci-Andrei self-requested a review March 27, 2026 11:50
@matbmapspeople matbmapspeople merged commit 0fc93a5 into main Mar 27, 2026
1 check passed
@matbmapspeople matbmapspeople deleted the feature/matb/fix_floor_selector_expansion_on_small_screens branch March 27, 2026 12:12
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