Skip to content
This repository was archived by the owner on Jan 21, 2019. It is now read-only.

Conversation

bkoval
Copy link
Contributor

@bkoval bkoval commented Nov 20, 2018

@Wikia/iwing

@bkoval bkoval requested a review from vforge as a code owner November 20, 2018 10:42
vforge
vforge previously requested changes Nov 20, 2018
Copy link
Collaborator

@vforge vforge left a comment

Choose a reason for hiding this comment

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

Few comments - mostly minor ones, but the complexity of this feels like a code smell.

Do you really need the Dropdown component to handle all that different situations? (ie. does the one Dropdown instance need to handle them)

In general it looks like we have WAY TOO MANY styles/behevious for a simple dropdown (that should be unified) - just the shadow has 3 different settings!

Also please remember that props !== classNames - limit the props if those are unneccessary.

Consider splitting Dropdown with different behaviors into different components, maybe to look like this:

  • Dropdown
    • DropdownLabel
    • DropdownItem
  • NestedDropdown
    • DropdownLabel
    • DropdownItem
  • StickedDropdown
    • DropdownLabel
    • DropdownItem

@bkoval
Copy link
Contributor Author

bkoval commented Nov 22, 2018

@vforge I rewrote the dropdown internals and improved the API, cutting out some props we did not really need.

Current implementation is compliant with the Ember one + it covers all cases we need. As for your idea to create multiple derrivatives of the main dropdown, I see only one possible derrivative - NestedDropdown, but it would still need to return Dropdown but with specific props set inside of it.

I'd say: let's merge the current dropdown (we're testing it as we develop it as we use it in Feeds) and then if we need more specific cases in the future, let's add them. What do you think?

@coveralls
Copy link

coveralls commented Nov 26, 2018

Pull Request Test Coverage Report for Build 524

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 500: 0.0%
Covered Lines: 328
Relevant Lines: 328

💛 - Coveralls


if (shouldPreventDefault) {
e.preventDefault();
e.stopPropagation();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need stop propagation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To prevent from running the handleClick() two times if the click takes place inside the toggle.

});
var toggleContentComponent;

if (typeof toggleContent === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to support jsx toggle content as well?

<Dropdown toggle={<div>my toggle</div>}>

Or function and string is enough? :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JSX is the else in this case :)

);
};
class DropdownToggle extends React.Component {
static getToggleContentComponent(toggleContent, isLevel2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest isNestedLevel or anything without number in it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.

</React.Fragment>
);
} else {
toggleContentComponent = toggleContent;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see no reason in accepting all three types, as this one can be merged with function one with () => <div />.

I'd check for === string and assume toggleContent is function in other case. docs will do the rest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually the most common case -> passing JSX as component toggle. Again - we enable this possiblity to be compliant with ember's design-system which accepts all three possibilities.


onMouseLeave() {
const { isTouchDevice } = this.state;
handleClick(shouldPreventDefault, e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need shouldPreventDefault flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To prevent from running the handleClick() two times if the click takes place inside the toggle.

@bkoval bkoval dismissed vforge’s stale review November 29, 2018 14:07

This pull request is hanging for some time with no additional feedback and has 2 approves already :)

@bkoval bkoval merged commit 1e2bbad into master Nov 29, 2018
@bkoval bkoval deleted the IW-1244 branch November 29, 2018 14:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants