Skip to content

Conversation

Ron-Lavi
Copy link
Collaborator

@Ron-Lavi Ron-Lavi commented Jun 10, 2018

Add DualListSelector component with storybook and tests. fix #379

Storybook
Design

f7948f4e-ad62-4def-y15b-08b40ee75f94

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch 3 times, most recently from b15e46c to 3cf32ac Compare June 13, 2018 15:38
@ohadlevy
Copy link
Member

@LaViro can you please rebase? thanks

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from 3cf32ac to 7cac4ed Compare June 20, 2018 09:18
@Ron-Lavi Ron-Lavi self-assigned this Jun 20, 2018
@Ron-Lavi Ron-Lavi changed the title [W.I.P] feat(DualListSelector): add a Dual List Selector component feat(DualListSelector): add a Dual List Selector component Jun 20, 2018
@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from 7cac4ed to 5ae4a54 Compare June 20, 2018 09:37
@jeff-phillips-18
Copy link
Member

@patternfly/patternfly-react-ux Can someone self-assign to do the UX review please?

@Rohoover
Copy link
Member

Adding my comments from slack to here for everyone's visibility:

I'm seeing some alignment issues at the top with the filter input colliding with the top of the pane. Additionally the select all checkbox is slightly lower than expected. Other than that it looks and functions very well. Nice work!

@Rohoover Rohoover self-assigned this Jun 20, 2018
@patternfly-build
Copy link
Contributor

Deploy preview for patternfly-react ready!

Built with commit 5ae4a54

https://deploy-preview-395--patternfly-react.netlify.com

import DualList from './DualList';
import mockLists from './mockLists';

test('patternfly Icon is working', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test does not cover anything other than the initial render. The snapshot is also ~450 lines. Anything over ~30 lines tends to not be that useful since people just skip looking at them.

It would be better to test the actual logic of the component (sorting, filtering, moving, etc).

items={items}
filterResults={filterResults}
filterTerm={filterTerm}
onChange={e => onItemChange(e)}
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be written as onChange={onItemChange}

/>
) : (
<div className="pf-dual-list-no-items">
{filterResults ? 'No items were found' : 'No items to show'}
Copy link
Contributor

Choose a reason for hiding this comment

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

these strings should be able to be passed in from props. That will enable localization/translation.


const DualListCounter = ({ selected, total }) => (
<strong>
{selected} of {total} items selected
Copy link
Contributor

Choose a reason for hiding this comment

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

same with this. maybe make it something like props.getSelectedMessage(selected, total)

<input
type="checkbox"
name={item.name}
onChange={e => onChange(e)}
Copy link
Contributor

Choose a reason for hiding this comment

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

onChange={onChange}

const DualListFilter = ({ onChange, side }) => (
<span className="pf-dual-list-filter">
<input
onChange={e => onChange(e)}
Copy link
Contributor

Choose a reason for hiding this comment

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

onChange={onChange}

}
}

DualList.propTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like currently, you can't do anything with the list values? It is all contained in local state. This needs to either be controlled by having the consumer manage the lists through callbacks and values or an onChange needs to be available. Controlled is a more work, but usually gives more freedom to the consumer.

@Ron-Lavi
Copy link
Collaborator Author

@Rohoover thanks !
I have fixed the issues you've mentioned,
Do you see more UX issues? thanks

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from 587d2a4 to 1c46f33 Compare August 14, 2018 08:28
@Rohoover
Copy link
Member

@LaViro
One thing I noticed, is that when I use filter you've cleverly more boldly the letters that match in the results, however it's difficult to see because the text in the boxes is already bold. My suggestion is either make the matching letters even more bold, or perhaps a highlight on the letters. Thoughts?

@Ron-Lavi
Copy link
Collaborator Author

@Rohoover
Does font-weight: 400 to the list item is enough ?
selection_042

@Ron-Lavi
Copy link
Collaborator Author

@Rohoover I saw that in Foreman they use titles in the selectors:
selection_043

Should we add that option?

Copy link
Member

@Rohoover Rohoover left a comment

Choose a reason for hiding this comment

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

@LaViro
The new bolded type looks better, thank you.

As for the titles... I'm not sure we have room...
I like the titles while at the same time want to stick with the original design.

Maybe @mcarrano would have an opinion.

@mcarrano
Copy link
Member

I agree with @Rohoover . Not sure that we have room nor do I think they add that much clarity, for example "All items" could be confusing if the list on the left is only a subset of items that are available to this task.

@Rohoover
Copy link
Member

@mcarrano
Another thought I had... any title could be added above the dual list selector panes. In other words, not having the titles doesn't prohibit a development team from adding it to the page in context to the selectors.

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch 4 times, most recently from 3b2d915 to b4faec7 Compare September 2, 2018 19:57
@coveralls

This comment has been minimized.

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from b4faec7 to 2ca97d4 Compare September 2, 2018 20:13
@jeff-phillips-18
Copy link
Member

Should this component be added to the patternfly-react-extensions package instead?

const isParent = itemsCopy[index].children;
if (isParent) {
// update the item's children check state.
itemsCopy[index].children.forEach(child => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we abstract some of this logic out into testable functions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could it wait for a follow up PR?
I think we should let users play with this component and get more feedback.
as I see it, the DualList is kind of an helper to DualListControlled as it receives all of data in a clean way.

I agree adding helpers to Dual List could make things more clear,
though this means breaking many things right now and testing many use cases again.

Copy link
Member

@cdcabrera cdcabrera left a comment

Choose a reason for hiding this comment

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

First up, appreciate the effort, it does show! much appreciated! But feel a re-evaluation around carrying props over to related components needs to take place.

Reasons:

  • quite a few repeated props
    • this does come across as an effort to avoid having to update multiple components, that is a valid reason, however...
  • there are also misaligned props, for example onChange vs onItemChange, see comments

Currently a few of these components simply reference other components' props. That can work in some cases, but...

Possible solutions:

It may be a little clearer if the props are either:

  • redeclared in their respective components, granted that is a bit of extra around updating
  • or the props all come from a single source instead of a multitude of components
  • or another possibility is to look at passing the props down, instead of pulling them from a child. This could happen through a generic ...props.
    • This also happens to work if the intention is to have a child only ever used internally

@Ron-Lavi
Copy link
Collaborator Author

Ron-Lavi commented Dec 9, 2018

Thanks @cdcabrera !!
Going to look over duplicated props.
as for the onChange and onItemChange,
the onChange is a callback returned to the consumer when items have been moved between lists.
the onItemChange is when the list item select state is toggled.

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from fc02a58 to e02768d Compare December 9, 2018 15:51
@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from e02768d to c06ada8 Compare December 10, 2018 16:34
dtaylor113
dtaylor113 previously approved these changes Dec 10, 2018
Copy link
Member

@dtaylor113 dtaylor113 left a comment

Choose a reason for hiding this comment

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

@LaViro addressed my review comments, so LGTM, but understand there may be other review comments which may need to be addressed -thanks

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

Copy link
Member

@cdcabrera cdcabrera left a comment

Choose a reason for hiding this comment

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

Just a few basics around questions, and some minor syntax clean up. Overall, after this, looking good for me

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from a6ebfa8 to a06f862 Compare December 11, 2018 14:37
@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

@Ron-Lavi
Copy link
Collaborator Author

Hey guys, fixed all of your suggestions,
but... found some bugs on filters functionality, please don't review yet.

thanks

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from a06f862 to 0593c6f Compare December 12, 2018 16:05
@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from 0593c6f to fcce2fe Compare December 13, 2018 13:38
@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from fcce2fe to ebfa606 Compare December 13, 2018 15:02
@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

@Ron-Lavi Ron-Lavi force-pushed the feature/dual-list-selector branch from ebfa606 to 16dcf34 Compare December 13, 2018 15:42
@Ron-Lavi
Copy link
Collaborator Author

Hey guys, feel free to review now :)

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh

Copy link
Member

@cdcabrera cdcabrera left a comment

Choose a reason for hiding this comment

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

This has been a ton of effort @LaViro and it shows kudos!

Just a few notes for a potential round two... looking forward to seeing some actions responses on/through storybook, and some expanded unit tests on those helpers. But going to defer to someone else on those aspects

sortBy: 'label',
filterTerm: '',
isMainChecked: false
});
Copy link
Member

Choose a reason for hiding this comment

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

note:
Default props in 2 locations, understand why it was done, but it's an indicator for a potential fail/frustration point for anyone trying to update this component.

At minimum a note or reference to this location needs to be called out possibly in the DualList.js file around DualList.defaultProps = {.

Others, of us, may want this to just be a reference to default props contained within the DualList class with something like DualList.defaultProps.left, I'll leave that up to you

@Ron-Lavi
Copy link
Collaborator Author

Pleasure to work with you guys !
Great follow ups suggestions :) :)

@jeff-phillips-18 jeff-phillips-18 merged commit 8c3447f into patternfly:master Dec 13, 2018
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.

Component: Dual List Selector