Skip to content

Commit

Permalink
fix: remove stopPropagation usages
Browse files Browse the repository at this point in the history
  • Loading branch information
HellWolf93 committed Aug 3, 2020
1 parent 9f52c7c commit d71867d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
7 changes: 0 additions & 7 deletions src/components/InternalDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,10 @@ const InternalDropdown = forwardRef((props, reference) => {
return handleChange(rest);
};

const handleTabKeyPressed = event => {
if (showCheckbox && event.target.tagName !== 'BUTTON') {
event.stopPropagation();
}
};

const keyHandlerMap = {
[UP_KEY]: handleKeyUpPressed,
[DOWN_KEY]: handleKeyDownPressed,
[ENTER_KEY]: handleKeyEnterPressed,
[TAB_KEY]: handleTabKeyPressed,
};

const handleKeyPressed = event => {
Expand Down
12 changes: 8 additions & 4 deletions src/components/MultiSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ const MultiSelect = React.forwardRef((props, ref) => {
};

const handleKeyDown = event => {
if ((event.keyCode === ESCAPE_KEY || event.keyCode === TAB_KEY) && isOpen) {
event.preventDefault();
closeAndFocusInput();
if (isOpen) {
if (
event.keyCode === ESCAPE_KEY ||
(event.keyCode === TAB_KEY && !(showCheckbox && event.target.tagName !== 'BUTTON'))
) {
event.preventDefault();
closeAndFocusInput();
}
}
if (event.target !== comboboxRef.current) return;
if (event.keyCode === ENTER_KEY || event.keyCode === SPACE_KEY) {
Expand Down Expand Up @@ -134,7 +139,6 @@ const MultiSelect = React.forwardRef((props, ref) => {

const handleTriggerClick = event => {
event.preventDefault();
event.stopPropagation();
toggleDropdown();
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/Option/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class OptionItem extends Component {
const { disabled, privateOnClick, label, name, icon, value, showCheckbox } = this.props;
if (showCheckbox) {
event.preventDefault();
event.stopPropagation();
}
if (disabled) {
event.preventDefault();
Expand All @@ -79,7 +78,6 @@ class OptionItem extends Component {
handleOnlyClick(event) {
const { disabled, privateOnClick, label, name, icon, value } = this.props;
event.preventDefault();
event.stopPropagation();

if (disabled) {
event.preventDefault();
Expand Down

0 comments on commit d71867d

Please sign in to comment.