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

fix: improve the MultiSelect component #1659

Merged

Conversation

HellWolf93
Copy link
Collaborator

fix: #1645

Changes proposed in this PR:

@commit-lint
Copy link

commit-lint bot commented Jun 25, 2020

Bug Fixes

  • improve the MultiSelect component (e3894f1)
  • add counter and use truncated text (0db1cd5)
  • uncheck item when selected and clicked (d5e58e1)
  • render uncheck icon when active or hover while selected (7f8a4b0)
  • rename hasChips to hasContent (04907dd)
  • minor refactor on MultiSelect component (c5bfda9)
  • add right margin to StyledCountText when readOnly (6c1ba86)
  • improve getContent function readability (6285055)
  • hide remove button from chip when readOnly and only one chip (e3c7acc)
  • refactor chips delete callback handling (95fd79f)
  • move value declaration outside of example component (a9cc0bf)
  • show uncheck icon in Option only when multiple (b113f69)
  • integration tests (f64985a)
  • pageObject methods comments (4600f8a)

Documentation

  • add readOnly example to MultiSelect component (f19835d)

Contributors

@HellWolf93, @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

src/components/MultiSelect/helpers/getContent.js Outdated Show resolved Hide resolved
src/components/MultiSelect/index.js Outdated Show resolved Hide resolved
Comment on lines 182 to 187
onFocus={onFocus}
onBlur={onBlur}
onKeyDown={handleKeyDown}
tabIndex={tabIndex}
tabIndex="-1"
ref={comboboxRef}
aria-labelledby={labelId}
Copy link
Contributor

@yvmunayev yvmunayev Jun 26, 2020

Choose a reason for hiding this comment

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

It is not clear to me that it works here.

  • Why is a div who handles the focus ?.
  • Div does not support tapIndex attributes.
  • What happens when the component is readOnly? who has the tapIndex, because the readOnly inputable are fucusable.

@TahimiLeonBravo why when readonly can't it be focusable?

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly

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

src/components/MultiSelect/index.js Outdated Show resolved Hide resolved
/>
));
return value.map(val => {
const onDeleteCallback = disabled || readOnly ? null : () => onDelete(val);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this logic works best in the handleDelete declaration in the parent component. It is only once and you don't have to be passing disable and readonly to this component.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Each chip should call handleDelete with its own value, and the only way of doing it that occurred to me is this way, I will be thankful if you could explain to me how do you think it will be better

Copy link
Member

@LeandroTorresSicilia LeandroTorresSicilia Jun 27, 2020

Choose a reason for hiding this comment

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

@HellWolf93 I think whats @yvmunayev meant is to use this logic in parent component and then pass below a prop which could be null or a function then here you do not need to use disabled and readOnly and also repeat the logic

const hasRightIcon = !!(icon && iconPosition === 'right');
if (currentValues && currentValues.includes(name)) {
if (activeOptionName === name) {
return <StyledUncheckIcon />;
}

Choose a reason for hiding this comment

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

this will affect the piclklist too, how we can avoid this?

Choose a reason for hiding this comment

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

I think we could pass down the multiple prop through context and then only render the uncheck icon when is multiple thus simple usages like in Picklist will be not affected

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 LeandroTorresSicilia merged commit 7abe1f6 into nexxtway:master Jun 29, 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.

fix: improve the MultiSelect component
4 participants