Skip to content

Commit

Permalink
remove obsolete code; move options next to current value
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeckem committed Dec 19, 2023
1 parent 6495262 commit c9c5fe8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/packages/basemap-switcher/BasemapSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const BasemapSwitcher: FC<BasemapSwitcherProps> = (props) => {
options.push(emptyOption);
}

const selectedLayer = options.filter((l) => l.layer === activeBaseLayer)[0];
const selectedLayer = options.find((l) => l.layer === activeBaseLayer);
return { options, selectedLayer };
}, [allowSelectingEmptyBasemap, baseLayers, map?.layers]);

Expand All @@ -113,6 +113,7 @@ export const BasemapSwitcher: FC<BasemapSwitcherProps> = (props) => {
aria-labelledby={ariaLabelledBy}
className="basemap-switcher-select"
classNamePrefix="react-select"
options={options}
value={selectedLayer}
onChange={(option) => option && activateLayer(option.value)}
isClearable={false}
Expand All @@ -128,7 +129,6 @@ export const BasemapSwitcher: FC<BasemapSwitcherProps> = (props) => {
}
isOptionDisabled={(option) => option?.layer?.loadState === "error"}
components={components}
options={options}
/>
) : null}
</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/samples/test-toc/toc-app/AppUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function AppUI() {
</Box>
}
>
<Flex flex="1" direction="column" position="relative">
<Flex flex="1" direction="column">
<MapContainer
mapId={MAP_ID}
role="main"
Expand Down Expand Up @@ -65,6 +65,7 @@ export function AppUI() {
>
<Toc
mapId={MAP_ID}
showTools={true}
basemapSwitcherProps={{
allowSelectingEmptyBasemap: true
}}
Expand Down
21 changes: 1 addition & 20 deletions src/samples/test-toc/toc-app/app.css
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
@media only screen and (max-width: 500px) {
.search-top-center-placement {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
z-index: 1;
}
}

@media only screen and (min-width: 501px) {
.search-top-center-placement {
position: absolute;
left: 50%;
top: 0px;
transform: translate(-50%, 0px);
width: 500px;
z-index: 1;
}
}
/* suppress empty file warning */

0 comments on commit c9c5fe8

Please sign in to comment.