Skip to content

Commit

Permalink
Mobile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
neokore committed Dec 2, 2020
1 parent 20e5fc4 commit fc00ac1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/api/UserDatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export const getUserDatasets = async (credentials, opts = {}) => {
}

// only cartodbfied and user datasets
const allowedSchemas = [credentials.username, 'public'];
return data.result.filter(
(d) => d.cartodbfied && d.table_schema === credentials.username
(d) => d.cartodbfied && allowedSchemas.includes(d.table_schema)
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/ui/theme/carto-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export const cartoThemeOptions = {
// Mapbox controls
'.mapboxgl-ctrl-bottom-left, .mapboxgl-ctrl-bottom-right': {
'@media (max-width: 600px)': { // sm
bottom: spacing(4)
bottom: spacing(16)
}
}
},
Expand Down Expand Up @@ -740,7 +740,7 @@ export const cartoThemeOptions = {
'&.colorPrimary': {
backgroundColor: variables.palette.text.primary,
}
},
}
},

// Tab
Expand Down
23 changes: 20 additions & 3 deletions src/widgets/GeocoderWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,21 @@ function GeocoderWidget(props) {
};

const handleKeyPress = async (e) => {
if (credentials && e.keyCode === 13) {
if (e.keyCode === 13) {
// Force blur to hide virtual keyboards on mobile and search
e.target.blur();
}
};

// Needed to handle keyboard "Done" button on iOS
const handleBlur = async () => {
if (searchText.length) {
handleSearch();
}
};

const handleSearch = async () => {
if (credentials) {
try {
setLoading(true);
const result = await geocodeStreetPoint(credentials, {
Expand All @@ -115,7 +129,7 @@ function GeocoderWidget(props) {
setLoading(false);
}
}
};
}

const zoomToResult = (result) => {
dispatch(
Expand All @@ -142,14 +156,17 @@ function GeocoderWidget(props) {
<Paper className={`${props.className} ${classes.paperInput}`} elevation={2}>
{loading ? <CircularProgress size={20} className={classes.icon} /> : <SearchIcon className={classes.icon}/>}
<InputBase
type="search"
tabIndex={-1}
inputRef={inputRef}
size='small'
placeholder='Search address'
className={classes.input}
value={searchText}
onChange={handleChange}
onInput={handleInput}
onKeyDown={handleKeyPress}/>
onKeyDown={handleKeyPress}
onBlur={handleBlur}/>
{result && <IconButton onClick={clearResult} className={classes.clear}>
<Close className={classes.icon}/>
</IconButton>}
Expand Down

0 comments on commit fc00ac1

Please sign in to comment.