Skip to content

feat(map-control): add className prop#967

Open
pudek357 wants to merge 1 commit intovisgl:mainfrom
pudek357:feat/map-control-classname
Open

feat(map-control): add className prop#967
pudek357 wants to merge 1 commit intovisgl:mainfrom
pudek357:feat/map-control-classname

Conversation

@pudek357
Copy link
Copy Markdown

@pudek357 pudek357 commented Apr 17, 2026

Summary

Adds an optional className prop to <MapControl> so users can style the control container element. Since MapControl renders its children into a detached <div> via createPortal (which is then handed to the Maps JavaScript API and positioned by the control-layout algorithm), there is currently no way for consumers to target that wrapping element from the React tree - the new prop closes that gap.

The implementation mirrors the existing className handling in sibling components (AdvancedMarker, InfoWindow): an effect syncs the prop to the DOM node as controlContainer.className = className ?? ''.

Changes

  • src/components/map-control.tsx — add optional className prop and a useEffect that syncs it to the portal container.
  • src/components/__tests__/map-control.test.tsx — add unit tests covering initial application, updates, and unset/removal of className.
  • docs/api-reference/components/map-control.md — document the new prop under an "Optional" section.

Test plan

  • npm run test:linter passes
  • npm run test:prettier passes
  • npm run test:tsc passes
  • npm run test:unit -- map-control — 3/3 tests pass (1 existing + 2 new)
  • Full npm run test:unit suite: no new failures introduced (pre-existing ts-jest failures on main are unrelated to this change)

Notes for reviewers

  • No breaking changes; prop is optional and defaults to unset.
  • API mirrors className on other components in the library for consistency.
  • Happy to open a Discussion first if the maintainers prefer that flow for small additive props like this one — just let me know.

Expose an optional `className` prop on `<MapControl>` so users can style
the control container element.
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.

1 participant