Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Add scroll bar to geotags autosuggest
Browse files Browse the repository at this point in the history
  • Loading branch information
voidxnull committed Sep 4, 2016
1 parent 7bac4a1 commit c73540a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/components/add-tag-modal/form/geotag/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class GeotagSelect extends Component {
const client = new ApiClient(API_HOST);
const response = await client.searchGeotags(value.trim());

this.setState({ suggestions: response.geotags.slice(0, 5) });
this.setState({ suggestions: response.geotags });
}, 300);

_getSuggestionValue = (geotag) => geotag.name;
Expand Down Expand Up @@ -114,6 +114,10 @@ export default class GeotagSelect extends Component {
value: this.state.value
};

const theme = {
suggestionsContainer: 'autosuggest__suggestions_container autosuggest__suggestions_container-with-scroll'
};

return (
<div>
<input name="geotag" type="hidden" value={this.state.geotagId} />
Expand All @@ -122,6 +126,7 @@ export default class GeotagSelect extends Component {
inputProps={inputProps}
renderSuggestion={this._renderSuggestion}
suggestions={this.state.suggestions}
theme={theme}
onSuggestionSelected={this._handleSelect}
onSuggestionsUpdateRequested={this._getSuggestions}
{...this.props}
Expand Down
13 changes: 10 additions & 3 deletions src/components/autosuggest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactAutosuggest from 'react-autosuggest';

import { omit } from 'lodash';

const theme = {
container: 'autosuggest__container',
Expand All @@ -14,8 +14,15 @@ const theme = {
sectionSuggestionsContainer: 'autosuggest__section_suggestions_container'
};

export default function Autosuggest(props) {
function Autosuggest(props) {
const combinedTheme = Object.assign(theme, props.theme);
props = omit(props, 'theme');

return (
<ReactAutosuggest theme={theme} {...props} />
<ReactAutosuggest theme={combinedTheme} {...props} />
);
}

Autosuggest.propTypes = ReactAutosuggest.propTypes;

export default Autosuggest;
5 changes: 5 additions & 0 deletions src/less/blocks/autosuggest.less
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
border-bottom-left-radius: @border-radius;
border-bottom-right-radius: @border-radius;
z-index: 1000;

&-with-scroll {
max-height: 200px;
overflow-y: scroll;
}
}

&__section {
Expand Down

0 comments on commit c73540a

Please sign in to comment.