-
Notifications
You must be signed in to change notification settings - Fork 9
Feature/matb/fix floor selector expansion on small screens #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matbmapspeople
merged 11 commits into
main
from
feature/matb/fix_floor_selector_expansion_on_small_screens
Mar 27, 2026
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a352a57
Enhance MapControls component with floor selector expansion detection…
matbmapspeople 8e96fa5
Add visibility control for bottom controls in MapControls when floor …
matbmapspeople faba81f
Release @mapsindoors/map-template@1.96.20 - Fix overlap issue between…
matbmapspeople 5619af2
Refactor MapControls to improve floor selector overlap detection and …
matbmapspeople dda22db
Refactor MapControls to utilize a custom hook for floor selector togg…
matbmapspeople 554e118
Update CHANGELOG to include new custom hook `useFloorSelectorToggleOb…
matbmapspeople 66d88cb
Update minZoom configuration in MapTemplate to use appConfig setting …
matbmapspeople 8255dbd
Update CHANGELOG to reflect the addition of configurable minZoom sett…
matbmapspeople 5c54c19
Update CHANGELOG and upgrade Web SDK to version 4.57.0 in MapTemplate…
matbmapspeople 0ed8544
build
matbmapspeople d366ee0
Remove console log from useEffect in MapTemplate to clean up code
matbmapspeople File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/map-template/src/hooks/useFloorSelectorToggleObserver.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { useEffect, useRef } from 'react'; | ||
|
|
||
| /** | ||
| * Observes the floor selector's toggle button class to detect open/close, | ||
| * then measures overlap after the expansion animation finishes. | ||
| * | ||
| * @param {Object} params | ||
| * @param {React.RefObject} params.floorSelectorRef - Ref to the floor selector element | ||
| * @param {Function} params.setIsFloorSelectorExpanded - State setter for floor selector expansion | ||
| * @param {Function} params.measureOverlap - Callback to measure overlap between floor selector and bottom controls | ||
| * @param {Object} params.mapsIndoorsInstance - MapsIndoors SDK instance (dependency trigger) | ||
| * @param {Object} params.mapInstance - Map instance (dependency trigger) | ||
| * @returns {React.RefObject<boolean>} isFloorSelectorOpenRef - Ref tracking whether the floor selector is open | ||
| */ | ||
| export function useFloorSelectorToggleObserver({ floorSelectorRef, setIsFloorSelectorExpanded, measureOverlap, mapsIndoorsInstance, mapInstance }) { | ||
| const overlapTimerRef = useRef(null); | ||
| const isFloorSelectorOpenRef = useRef(false); | ||
|
|
||
| useEffect(() => { | ||
| const floorSelector = floorSelectorRef.current; | ||
| if (!floorSelector) return; | ||
|
|
||
| const onClassChange = () => { | ||
| if (overlapTimerRef.current) { | ||
| clearTimeout(overlapTimerRef.current); | ||
| } | ||
|
|
||
| const button = floorSelector.querySelector('.mi-floor-selector__button'); | ||
| if (!button) return; | ||
|
|
||
| const isOpen = button.classList.contains('mi-floor-selector__button--open'); | ||
| isFloorSelectorOpenRef.current = isOpen; | ||
|
|
||
| if (!isOpen) { | ||
| setIsFloorSelectorExpanded(false); | ||
| return; | ||
| } | ||
|
|
||
| overlapTimerRef.current = setTimeout(measureOverlap, 50); | ||
| }; | ||
|
|
||
| const observer = new MutationObserver(onClassChange); | ||
| observer.observe(floorSelector, { | ||
| subtree: true, | ||
| attributes: true, | ||
| attributeFilter: ['class'] | ||
| }); | ||
|
|
||
| return () => { | ||
| observer.disconnect(); | ||
| if (overlapTimerRef.current) { | ||
| clearTimeout(overlapTimerRef.current); | ||
| } | ||
| }; | ||
| }, [floorSelectorRef, setIsFloorSelectorExpanded, measureOverlap, mapsIndoorsInstance, mapInstance]); | ||
|
|
||
| return isFloorSelectorOpenRef; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.