Skip to content

Commit

Permalink
Address some reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlurak committed Sep 20, 2024
1 parent 4c064db commit 27b73ec
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/components/SearchBox/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const SearchBoxInput = ({ params, setInputValue, autocompleteRef }) => {
const inputRef = React.useRef<HTMLInputElement>(null);

useKeyDown('/', (e) => {
const isInput = e.target instanceof HTMLInputElement;
const isTextarea = e.target instanceof HTMLTextAreaElement;
if (isInput || isTextarea) {
return;
}
e.preventDefault();
inputRef.current?.focus();
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/SearchBox/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { useFeatureContext } from '../utils/FeatureContext';
import { AutocompleteInput } from './AutocompleteInput';
import { t } from '../../services/intl';
import { ClosePanelButton } from '../utils/ClosePanelButton';
import { useMobileMode, useToggleState } from '../helpers';
import { useMobileMode } from '../helpers';
import { useInputValueState } from './options/geocoder';
import { useOptions } from './useOptions';
import { useGetOptions } from './useGetOptions';
import { HamburgerMenu } from '../Map/TopMenu/HamburgerMenu';
import { UserMenu } from '../Map/TopMenu/UserMenu';
import { DirectionsButton } from '../Directions/DirectionsButton';
Expand Down Expand Up @@ -48,7 +48,7 @@ const SearchBox = () => {
const autocompleteRef = useRef();
const onClosePanel = useOnClosePanel();

const options = useOptions(inputValue);
const options = useGetOptions(inputValue);

return (
<TopPanel $isMobileMode={isMobileMode}>
Expand Down
3 changes: 1 addition & 2 deletions src/components/SearchBox/onHighlightFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ export const getSkeleton = ({ geocoder }: GeocoderOption): Feature => {
const center = geocoder.geometry.coordinates;
const { osm_id: id, osm_type: osmType, name } = geocoder.properties;
const type = getElementType(osmType);
const [lon, lat] = center;

return {
center,
type: 'Feature',
skeleton: true,
nonOsmObject: false,
osmMeta: { type, id: parseInt(id, 10) },
center: [parseFloat(`${lon}`), parseFloat(`${lat}`)],
tags: { name },
properties: { class: geocoder.properties.class, subclass: '' },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getOverpassOptions } from './options/overpass';
import { getPresetOptions } from './options/preset';
import { Option } from './types';

export const useOptions = (inputValue: string) => {
export const useGetOptions = (inputValue: string) => {
const { view } = useMapStateContext();
const { stars } = useStarsContext();
const [options, setOptions] = useState<Option[]>([]);
Expand Down
8 changes: 0 additions & 8 deletions src/components/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,3 @@ export const ClientOnly = ({ children }) => {

export const isImperial = () =>
window.localStorage.getItem('imperial') === 'yes';

export const toggleImperial = (imperial?: boolean) => {
if (imperial === undefined) {
localStorage.setItem('imperial', isImperial() ? '' : 'yes');
return;
}
localStorage.setItem('imperial', imperial ? 'yes' : '');
};

0 comments on commit 27b73ec

Please sign in to comment.