Skip to content

Conversation

@JamesDiStef
Copy link

@JamesDiStef JamesDiStef commented Sep 16, 2025

…eft, bottom right

Summary by CodeRabbit

  • New Features

    • Add configurable modal position (topleft, topright, bottomleft, bottomright) for map and sidebar modals; defaults to topleft.
    • Modal position can be set via URL parameter when URL parameter support is enabled; value propagates to map and sidebar components at runtime.
  • Style

    • Modal CSS updated with corner-specific anchoring, offsets and z-index for consistent placement and layering.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

Walkthrough

Adds a new modalLocation prop across map-template components: declared and documented on MapsIndoorsMap, forwarded via MapTemplate to MapWrapper and Sidebar, consumed by Sidebar Modal components, and supported by new SCSS corner-position classes and URL-query/default handling.

Changes

Cohort / File(s) Change summary
Public prop plumbing: modalLocation
packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx, packages/map-template/src/components/MapTemplate/MapTemplate.jsx, packages/map-template/src/components/Sidebar/Sidebar.jsx, packages/map-template/src/components/Sidebar/Modal/Modal.jsx
Added modalLocation to function signatures, PropTypes, and JSDoc; MapsIndoorsMap adds default 'topleft' and URL query support (when enabled) and sets mapTemplateProps.modalLocation; MapTemplate forwards it to MapWrapper and Sidebar; Sidebar passes it to Modal wrappers.
Styling for modal locations
packages/map-template/src/components/Sidebar/Modal/Modal.scss
Removed default .modal top/left offsets and added corner variants .modal.topleft, .modal.topright, .modal.bottomleft, .modal.bottomright with explicit offsets and z-index for corner anchoring.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant URL as URL Query
  participant MIM as MapsIndoorsMap
  participant MT as MapTemplate
  participant SB as Sidebar
  participant MOD as Modal

  Note right of MIM: Initialization
  MIM->>MIM: Resolve modalLocation (URL param if supportsUrlParameters else prop/default)
  alt URL param present
    URL-->>MIM: modalLocation (query)
  end
  MIM->>MT: render with mapTemplateProps.modalLocation
  MT->>MT: forward modalLocation to MapWrapper and Sidebar
  MT->>SB: modalLocation
  SB->>MOD: modalLocation (applied to each Modal)
  MOD->>MOD: add CSS class ".modal.<location>" to container (topleft/topright/bottomleft/bottomright)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

minor

Suggested reviewers

  • ammapspeople

Poem

A rabbit hops and finds the spot,
Top-left, top-right, or bottom plot.
I pass the prop with eager cheer,
CSS carrots place it near.
Hooray—modals settle, corners bright! 🥕🐇

Pre-merge checks and finishing touches

✅ 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 clearly summarizes the primary change by stating that a new prop is added to configure modal positioning, and it directly reflects the main intent of the PR without unrelated details or file lists. Although it uses a conventional “feature:” prefix and lists some positions, it remains concise and focused on the core update.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 902a54a and 66c8752.

📒 Files selected for processing (1)
  • packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (5 hunks)
🔇 Additional comments (1)
packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (1)

104-188: Restore modalLocation default fallback

When neither the prop nor the URL query is provided, mapTemplateProps.modalLocation stays undefined, so the sidebar modal never receives any of the new placement classes. On layouts that relied on the base offsets being removed this breaks the modal positioning. Please fall back to the declared default ('topleft') whenever both inputs are missing.

Apply:

-            modalLocation: props.supportsUrlParameters && modalLocationQueryParameter ? modalLocationQueryParameter : props.modalLocation,
+            modalLocation: (props.supportsUrlParameters && modalLocationQueryParameter)
+                ? modalLocationQueryParameter
+                : (props.modalLocation || defaultProps.modalLocation),

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.

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/map-template/src/components/Sidebar/Sidebar.jsx (1)

108-113: EXTERNALIDS modal missing modalLocation (regression in placement)

All other modals receive modalLocation. With base offsets removed, EXTERNALIDS will have no anchor and may render unpredictably.

Apply:

-        <Modal isOpen={currentAppView === appViews.EXTERNALIDS} key="EXTERNALIDS">
+        <Modal isOpen={currentAppView === appViews.EXTERNALIDS} key="EXTERNALIDS" modalLocation={modalLocation}>
🧹 Nitpick comments (8)
packages/map-template/src/components/Sidebar/Modal/Modal.scss (1)

54-81: Corner classes: kiosk conflict, hardcoded offsets, and z-index regression

  • The corner selectors will override .modal--kiosk (same specificity, later in file). Result: kiosk modals won’t stay centered. Scope corner rules to non‑kiosk.
  • Replace magic 10px/100px with spacing tokens for consistency; also the 100px asymmetry looks accidental.
  • Switching to --z-index-dropdown may push the modal under overlayed UI; keep --z-index-overlay unless intentionally changed.

Apply:

-    &.topleft {
-        top: 10px;
-        left: 10px;
+    &:not(.modal--kiosk).topleft {
+        top: var(--spacing-medium);
+        left: var(--spacing-medium);
         right: auto;
         bottom: auto;
-        z-index: var(--z-index-dropdown);
+        z-index: var(--z-index-overlay);
     }
-    &.topright {
-        top: 10px;
-        right: 100px;
+    &:not(.modal--kiosk).topright {
+        top: var(--spacing-medium);
+        right: var(--spacing-medium);
         left: auto;
         bottom: auto;
-        z-index: var(--z-index-dropdown);
+        z-index: var(--z-index-overlay);
     }
-    &.bottomleft {
-        bottom: 10px;
-        left: 100px;
+    &:not(.modal--kiosk).bottomleft {
+        bottom: var(--spacing-medium);
+        left: var(--spacing-medium);
         top: auto;
         right: auto;
-        z-index: var(--z-index-dropdown);
+        z-index: var(--z-index-overlay);
     }
-    &.bottomright {
-        bottom: 10px;
-        right: 10px;
+    &:not(.modal--kiosk).bottomright {
+        bottom: var(--spacing-medium);
+        right: var(--spacing-medium);
         left: auto;
         top: auto;
-        z-index: var(--z-index-dropdown);
+        z-index: var(--z-index-overlay);
     }
packages/map-template/src/components/Sidebar/Modal/Modal.jsx (2)

9-11: Constrain and document modalLocation

  • Use oneOf to prevent invalid class names.
  • Add JSDoc for modalLocation.

Apply:

 Modal.propTypes = {
   children: PropTypes.node,
-  isOpen: PropTypes.bool,
-  modalLocation: PropTypes.string
+  isOpen: PropTypes.bool,
+  modalLocation: PropTypes.oneOf(['topleft','topright','bottomleft','bottomright'])
 };
@@
- function Modal({ children, isOpen, modalLocation }) {
+ /**
+  * @param {'topleft'|'topright'|'bottomleft'|'bottomright'} [props.modalLocation]
+  */
+ function Modal({ children, isOpen, modalLocation }) {

Also applies to: 23-23


36-49: Guard refs correctly in MutationObserver effect

if (!contentRef) never trips; check contentRef.current and modalRef.current before use.

Apply:

-    useEffect(() => {
-        if (!contentRef) return;
+    useEffect(() => {
+        if (!contentRef?.current || !modalRef?.current) return;
         const observer = new MutationObserver(() => {
-            const contentHeight = contentRef.current.clientHeight;
-            const modalHeight = modalRef.current?.clientHeight;
+            const contentHeight = contentRef.current?.clientHeight ?? 0;
+            const modalHeight = modalRef.current?.clientHeight ?? 0;
             setFullHeight(contentHeight > modalHeight);
         });
packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (2)

40-42: Type and docs: enumerate allowed modalLocation values

Align PropTypes and JSDoc with the four supported tokens and exact spellings (no space).

Apply:

-    mapboxMapStyle: PropTypes.string,
-    modalLocation: PropTypes.string,
+    mapboxMapStyle: PropTypes.string,
+    modalLocation: PropTypes.oneOf(['topleft','topright','bottomleft','bottomright']),
@@
- * @param {string} [props.modalLocation] - Specifies where the modal renders - default to top left. other options include topright, bottomleft, or bottomright.
+ * @param {'topleft'|'topright'|'bottomleft'|'bottomright'} [props.modalLocation] - Corner where the modal renders. Default: 'topleft'.

Also applies to: 80-81


140-141: Normalize query param value

Lowercase once to tolerate case variants; optional: strip hyphen.

Apply:

-        const modalLocationQueryParameter = queryStringParams.get('modalLocation');
+        const modalLocationQueryParameter = queryStringParams.get('modalLocation')?.toLowerCase()?.replace('-', '');
packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1)

103-105: PropTypes/JSDoc tighten; optional default in signature

  • Use oneOf for modalLocation and correct JSDoc spelling.
  • Optionally default in the signature for resilience.

Apply:

-    mapboxMapStyle: PropTypes.string,
-    modalLocation: PropTypes.string,
+    mapboxMapStyle: PropTypes.string,
+    modalLocation: PropTypes.oneOf(['topleft','topright','bottomleft','bottomright']),
@@
- * @param {string} [props.modalLocation] - Specifies where the modal renders - default to top left. other options include topright, bottomleft, or bottomright.
+ * @param {'topleft'|'topright'|'bottomleft'|'bottomright'} [props.modalLocation] - Corner where the modal renders. Default: 'topleft'.
@@
-function MapTemplate({ ... , mapboxMapStyle, modalLocation }) {
+function MapTemplate({ ... , mapboxMapStyle, modalLocation = 'topleft' }) {

Also applies to: 142-145

packages/map-template/src/components/Sidebar/Sidebar.jsx (2)

40-41: Docs mismatch with implementation

JSDoc lists "centered" and omits "topleft/topright". Align with the four supported tokens.

Apply:

- * @param {string} props.modalLocation - The location of the modal in the sidebar. Can be "bottomright", "bottomleft", "centered".
+ * @param {'topleft'|'topright'|'bottomleft'|'bottomright'} props.modalLocation - Corner position for the modal.

15-24: Constrain modalLocation PropType

Use an enum to prevent invalid values.

Apply:

-    onRouteFinished: PropTypes.func,
-    modalLocation: PropTypes.string
+    onRouteFinished: PropTypes.func,
+    modalLocation: PropTypes.oneOf(['topleft','topright','bottomleft','bottomright'])
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64852ce and 1e60aaf.

📒 Files selected for processing (6)
  • packages/map-template/src/App.jsx (1 hunks)
  • packages/map-template/src/components/MapTemplate/MapTemplate.jsx (3 hunks)
  • packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (5 hunks)
  • packages/map-template/src/components/Sidebar/Modal/Modal.jsx (3 hunks)
  • packages/map-template/src/components/Sidebar/Modal/Modal.scss (1 hunks)
  • packages/map-template/src/components/Sidebar/Sidebar.jsx (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/map-template/src/components/Sidebar/Modal/Modal.jsx (2)
packages/map-template/src/components/Sidebar/Sidebar.jsx (1)
  • kioskLocation (46-46)
packages/map-template/src/components/LocationDetails/LocationDetails.jsx (1)
  • kioskLocation (87-87)
packages/map-template/src/components/Sidebar/Sidebar.jsx (1)
packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1)
  • pushAppView (209-209)
🔇 Additional comments (2)
packages/map-template/src/App.jsx (1)

11-12: LGTM: call‑site threads modalLocation

Passing modalLocation='topright' exercises the new flow end‑to‑end.

packages/map-template/src/components/MapTemplate/MapTemplate.jsx (1)

800-801: LGTM: prop is forwarded to Sidebar

Prop threading looks correct.

Comment on lines +103 to 105
useAppTitle: false,
modalLocation: 'topleft',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Default not applied: modalLocation can be undefined

defaultProps.modalLocation is declared but not used when neither prop nor URL param is set. This breaks positioning after base offsets were removed.

Apply:

-            modalLocation: 'topleft',
+            modalLocation: 'topleft',
@@
-            modalLocation: props.supportsUrlParameters && modalLocationQueryParameter ? modalLocationQueryParameter : props.modalLocation,
+            modalLocation: (props.supportsUrlParameters && modalLocationQueryParameter)
+                ? modalLocationQueryParameter
+                : (props.modalLocation || defaultProps.modalLocation),

Also applies to: 185-186

🤖 Prompt for AI Agents
In packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx around
lines 103-105 (and similarly at 185-186), defaultProps.modalLocation is declared
but not applied when neither the prop nor the URL param is present; update the
code to select modalLocation with a clear precedence (prop value -> URL param ->
defaultProps.modalLocation) so the default is used when others are undefined
(implement via destructuring default, nullish coalescing, or explicit fallback),
and apply the same fix at the other occurrence on lines 185-186.

Comment on lines 51 to 53
return <div ref={modalRef}
className={`modal ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
className={`modal ${modalLocation} ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid "undefined" CSS class and skip location class in kiosk

Prevent rendering class="undefined" and avoid corner class when kiosk is active.

Apply:

-    return <div ref={modalRef}
-        className={`modal ${modalLocation} ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
-    >
+    const locationClass = !kioskLocation && modalLocation ? modalLocation : '';
+    return <div ref={modalRef}
+        className={`modal ${locationClass} ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
+    >
📝 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
return <div ref={modalRef}
className={`modal ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
className={`modal ${modalLocation} ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
>
const locationClass = !kioskLocation && modalLocation ? modalLocation : '';
return <div ref={modalRef}
className={`modal ${locationClass} ${isOpen ? 'modal--open' : ''} ${fullHeight ? 'modal--full' : ''} ${kioskLocation ? 'modal--kiosk' : ''}`}
>
🤖 Prompt for AI Agents
In packages/map-template/src/components/Sidebar/Modal/Modal.jsx around lines
51-53, the className string can include "undefined" when modalLocation is falsy
and still adds the corner/location class even when kioskLocation is true; update
the className construction to build classes conditionally (e.g., use an array of
class tokens and push modalLocation only if it's a non-empty string, push
'modal--kiosk' only when kioskLocation is truthy, and skip adding modalLocation
when kioskLocation is active), then join the array with spaces (or use
conditional expressions) so no "undefined" token is emitted and the location
class is omitted in kiosk mode.

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: 0

🧹 Nitpick comments (1)
packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (1)

7-41: Declare modalLocation in propTypes.

New public prop isn’t reflected in the PropTypes contract, so downstream consumers lose type guidance. Please add it (e.g. as a oneOf of the supported values).

     showMapMarkers: PropTypes.bool,
     mapboxMapStyle: PropTypes.string,
-    devicePosition: PropTypes.object
+    devicePosition: PropTypes.object,
+    modalLocation: PropTypes.oneOf(['topleft', 'topright', 'bottomleft', 'bottomright'])
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 803e88a and 902a54a.

📒 Files selected for processing (2)
  • packages/map-template/src/components/MapTemplate/MapTemplate.jsx (3 hunks)
  • packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/map-template/src/components/MapTemplate/MapTemplate.jsx
🔇 Additional comments (1)
packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx (1)

186-186: Default modal location still isn’t applied.

When neither URL param nor prop is provided, this leaves modalLocation undefined, so the modal loses its positioning class after the base styles were removed. Please fall back to the default.

-            modalLocation: props.supportsUrlParameters && modalLocationQueryParameter ? modalLocationQueryParameter : props.modalLocation,
+            modalLocation: (props.supportsUrlParameters && modalLocationQueryParameter)
+                ? modalLocationQueryParameter
+                : (props.modalLocation ?? defaultProps.modalLocation),

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