Skip to content

Commit 583f231

Browse files
committed
feat(CompactMap): add autoExpandOnCarouselClick prop for opt-in auto-expand
Adds explicit control over auto-expand behavior with a new prop. New Prop: - autoExpandOnCarouselClick: boolean (default: false) - When true: clicking carousel card auto-expands to fullscreen - When false: users must click expand button manually Benefits: - Backward compatible (default: false preserves existing behavior) - Explicit opt-in for auto-expand UX - Developers can choose based on their use case - Doesn't force auto-expand on all CompactMap instances Implementation: - Added prop to CompactMapProps interface - Wrapped carousel onLocationSelect to conditionally call onExpand - Only triggers when prop is true AND location is selected AND onExpand exists Usage: <CompactMap locations={locations} onExpand={handleExpand} autoExpandOnCarouselClick={true} // Opt-in />
1 parent fd238fa commit 583f231

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/ui/src/components/Map/CompactMap.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export interface CompactMapProps extends Omit<MapViewProps, 'className' | 'style
5050
* Callback when user clicks the expand button to enter fullscreen.
5151
*/
5252
onExpand?: () => void;
53+
54+
/**
55+
* Auto-expand to fullscreen when user clicks a carousel card.
56+
* When true, selecting a location from the carousel automatically triggers onExpand.
57+
* When false, users must click the expand button manually.
58+
* @default false
59+
*/
60+
autoExpandOnCarouselClick?: boolean;
5361
}
5462

5563
const DEFAULT_HEIGHT = '478px';
@@ -76,6 +84,7 @@ export const CompactMap: React.FC<CompactMapProps> = ({
7684
mapStyle,
7785
carouselProps,
7886
onExpand,
87+
autoExpandOnCarouselClick = false,
7988
}) => {
8089
const containerStyle: React.CSSProperties = {
8190
...style,
@@ -121,7 +130,15 @@ export const CompactMap: React.FC<CompactMapProps> = ({
121130
<LocationCarousel
122131
locations={locations}
123132
selectedId={selectedId}
124-
onLocationSelect={onLocationSelect}
133+
onLocationSelect={(id) => {
134+
// Set selection first
135+
onLocationSelect?.(id);
136+
137+
// Then trigger fullscreen if auto-expand is enabled
138+
if (autoExpandOnCarouselClick && id !== undefined && onExpand) {
139+
onExpand();
140+
}
141+
}}
125142
loading={loading}
126143
error={error}
127144
{...carouselProps}

0 commit comments

Comments
 (0)