Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement showCheckbox prop on the MultiSelect component #1689

Merged

Conversation

HellWolf93
Copy link
Collaborator

fix: #1655

Changes proposed in this PR:

@commit-lint
Copy link

commit-lint bot commented Jul 6, 2020

Features

  • implement showCheckbox prop on the MultiSelect component (c3cb6dd)

Bug Fixes

  • improve MultiSelect component (5895389)
  • outside click not working (ed19091)
  • failing test cases (d89ec6c)
  • Option component test case failing (9f52c7c)
  • remove stopPropagation usages (d71867d)
  • remove unnecessary component in MultiSelect (36ca1d0)
  • refactor getAllValues to make it more functional (e4ef87e)
  • remove unused import (cd2141c)
  • remove unnecessary preventDefault (90b54f8)
  • move normalizeValue back to MultiSelect and fix tests (ff91bb5)
  • update normalizeValue import (a92942d)
  • remove unnecessary timeouts (191515a)
  • getAllValues missing icon and tests (eb81162)

Contributors

@HellWolf93, @TahimiLeonBravo, @LeandroTorresSicilia

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@LeandroTorresSicilia LeandroTorresSicilia added the WIP work in progress label Jul 7, 2020
src/components/Option/index.js Show resolved Hide resolved
src/components/Option/index.js Show resolved Hide resolved
src/components/Option/button.js Outdated Show resolved Hide resolved
@@ -207,10 +224,17 @@ const InternalDropdown = forwardRef((props, reference) => {
return handleChange(rest);
};

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must avoid doing stopPropagation take a look at what we did in Tree component (src/components/Tree/helpers/shouldSelectNode.js), instead of calling stopPropagation we did some kind of filter
What happens is that if someone use this component and in its implementation, he uses a global listener then it will not get this event, we must avoid this behavior.
I know we use it in other place and we need to fix them, but for now what we can do is no doing it anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

value: childValue,
});
}
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we should take a more functional approach like using map or reduce

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return (
<StyledHeader title={title} role="presentation" onMouseDown={onClick}>
<StyledPrimitiveCheckbox type="checkbox" label="" checked={isChecked} {...rest} />
<StyledHeaderLabel>{label}</StyledHeaderLabel>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there are two like this, other in the InternalDropdown, both are needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, just a leftover when moving the 'Select all' logic to the InternalDropdown component. Done.

const { disabled, privateOnClick, label, name, icon, value, showCheckbox } = this.props;
if (showCheckbox) {
event.preventDefault();
event.stopPropagation();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ^^ we need to avoid stopPropagation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const { disabled, privateOnClick, label, name, icon, value } = this.props;
event.preventDefault();
event.stopPropagation();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ^^

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@LeandroTorresSicilia
Copy link
Member

@HellWolf93 there are some tests failing

src/components/MultiSelect/index.js Show resolved Hide resolved
src/components/Option/index.js Show resolved Hide resolved
src/components/Option/index.js Outdated Show resolved Hide resolved
src/components/Option/index.js Outdated Show resolved Hide resolved
@LeandroTorresSicilia
Copy link
Member

when press the only button when some or all items are selected, included the pressed one,first it uncheck the same item that the only was pressed and then it trigger the only function, then it send to events, one removing the item and then setting this item only

@LeandroTorresSicilia
Copy link
Member

LeandroTorresSicilia commented Aug 4, 2020

When selecting all it does not send the icons, we need to add test to this in order to guarantee this functionality

@LeandroTorresSicilia
Copy link
Member

There unit test failing

@codeclimate
Copy link

codeclimate bot commented Aug 5, 2020

Code Climate has analyzed commit ed8b28d and detected 11 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3
Duplication 8

View more on Code Climate.

@LeandroTorresSicilia LeandroTorresSicilia merged commit f3477f6 into nexxtway:master Aug 5, 2020
@HellWolf93 HellWolf93 removed the WIP work in progress label Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: implement showCheckbox prop on the MultiSelect component
4 participants