Skip to content

Commit

Permalink
dynamically set width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Apr 18, 2018
1 parent 9fa163f commit 7380a41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
5 changes: 1 addition & 4 deletions src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export class EuiComboBox extends Component {

this.setState({
width: comboBoxBounds.width,
optionsListHeight: listBounds.height,
listPosition: position,
});
};
Expand Down Expand Up @@ -479,7 +478,7 @@ export class EuiComboBox extends Component {
...rest
} = this.props;

const { searchValue, isListOpen, listPosition, width, optionsListHeight } = this.state;
const { searchValue, isListOpen, listPosition, width, } = this.state;

const classes = classNames('euiComboBox', className, {
'euiComboBox-isOpen': isListOpen,
Expand All @@ -492,7 +491,6 @@ export class EuiComboBox extends Component {

if (!noSuggestions && isListOpen) {
console.log("width", width);
console.log("optionsListHeight", optionsListHeight);
optionsList = (
<EuiPortal>
<EuiComboBoxOptionsList
Expand All @@ -512,7 +510,6 @@ export class EuiComboBox extends Component {
position={listPosition}
renderOption={renderOption}
width={width}
height={optionsListHeight}
/>
</EuiPortal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
}

.euiComboBoxOptionsList__rowWrap {
@include euiScrollBar;

padding: $euiSizeS;
padding: 0;
max-height: 200px;
overflow-y: auto;
overflow: hidden;
}

.ReactVirtualized__List {
@include euiScrollBar;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ export class EuiComboBoxOptionsList extends Component {
listRef: PropTypes.func.isRequired,
renderOption: PropTypes.func,
width: PropTypes.number,
height: PropTypes.number
}

static defaultProps = {
height: 200,
}

updatePosition = () => {
Expand Down Expand Up @@ -102,7 +97,6 @@ export class EuiComboBoxOptionsList extends Component {
listRef, // eslint-disable-line no-unused-vars
updatePosition, // eslint-disable-line no-unused-vars
width,
height,
...rest
} = this.props;

Expand Down Expand Up @@ -151,12 +145,16 @@ export class EuiComboBoxOptionsList extends Component {

const groupLabelToGroupMap = {};

const optionHeight = 27; // TODO dynamically figure this out
const numVisiableOptions = matchingOptions.length < 7 ? matchingOptions.length : 7;
const height = numVisiableOptions * optionHeight;

const optionsList = (
<List
width={384}
height={184}
width={width}
height={height}
rowCount={matchingOptions.length}
rowHeight={27}
rowHeight={optionHeight}
rowRenderer={({ key, index, style }) => {
const option = matchingOptions[index];
const {
Expand Down

0 comments on commit 7380a41

Please sign in to comment.