Skip to content

Commit

Permalink
[fix] dropdown in color scale does not work
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <[email protected]>
  • Loading branch information
lixun910 authored and igorDykhta committed Sep 20, 2023
1 parent b3472a3 commit b37d590
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/components/src/common/item-selector/dropdown-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import classNames from 'classnames';
import styled from 'styled-components';
import {INIT_FILTER_ITEMS_IN_DROPDOWN} from '@kepler.gl/constants';

const LEFT_BUTTON = 0;

export const classList = {
list: 'list-selector',
listHeader: 'list__header',
Expand Down Expand Up @@ -180,7 +182,10 @@ export default class DropdownList extends Component<DropdownListProps, DropdownL

_onClick(result, event) {
event.preventDefault();
this.props.onOptionSelected?.(result, event);
// only work when left is clicked
if ((event.type === 'mousedown' && event.button === LEFT_BUTTON) || event.type === 'click') {
this.props.onOptionSelected?.(result, event);
}
}

render() {
Expand Down Expand Up @@ -218,13 +223,10 @@ export default class DropdownList extends Component<DropdownListProps, DropdownL
[classList.listItemFixed]: true
})}
key={`${display(value)}_${i}`}
onMouseDown={e => this._onClick(value, e)}
onClick={e => this._onClick(value, e)}
>
<CustomListItemComponent
value={value}
displayOption={display}
onOptionSelected={this.props.onOptionSelected}
/>
<CustomListItemComponent value={value} displayOption={display} />
</div>
))}
</div>
Expand All @@ -236,13 +238,10 @@ export default class DropdownList extends Component<DropdownListProps, DropdownL
hover: this.props.selectionIndex === i + valueOffset
})}
key={`${display(value)}_${i}`}
onMouseDown={e => this._onClick(value, e)}
onClick={e => this._onClick(value, e)}
>
<CustomListItemComponent
value={value}
displayOption={display}
onOptionSelected={this.props.onOptionSelected}
/>
<CustomListItemComponent value={value} displayOption={display} />
</div>
))}

Expand Down

0 comments on commit b37d590

Please sign in to comment.