-
Notifications
You must be signed in to change notification settings - Fork 481
Use the whole list item as the click target #3963
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,27 +9,53 @@ import classNames from 'classnames'; | |
| import { CSSTransition, TransitionGroup } from 'react-transition-group'; | ||
| import './FilterNavigatorBar.css'; | ||
|
|
||
| type FilterNavigatorBarButtonProps = {| | ||
| onClick: (number) => mixed, | ||
| index: number, | ||
| children: React.Node, | ||
| type FilterNavigatorBarListItemProps = {| | ||
| +onClick?: null | ((number) => mixed), | ||
| +index: number, | ||
| +isFirstItem: boolean, | ||
| +isLastItem: boolean, | ||
| +isSelectedItem: boolean, | ||
| +title?: string, | ||
| +additionalClassName?: string, | ||
| +children: React.Node, | ||
| |}; | ||
|
|
||
| class FilterNavigatorBarButton extends React.PureComponent<FilterNavigatorBarButtonProps> { | ||
| class FilterNavigatorBarListItem extends React.PureComponent<FilterNavigatorBarListItemProps> { | ||
| _onClick = () => { | ||
| const { index, onClick } = this.props; | ||
| onClick(index); | ||
| if (onClick) { | ||
| onClick(index); | ||
| } | ||
| }; | ||
|
|
||
| render() { | ||
| const { | ||
| isFirstItem, | ||
| isLastItem, | ||
| isSelectedItem, | ||
| children, | ||
| additionalClassName, | ||
| onClick, | ||
| title, | ||
| } = this.props; | ||
| return ( | ||
| <button | ||
| type="button" | ||
| className="filterNavigatorBarItemContent" | ||
| onClick={this._onClick} | ||
| <li | ||
| className={classNames('filterNavigatorBarItem', additionalClassName, { | ||
| filterNavigatorBarRootItem: isFirstItem, | ||
| filterNavigatorBarSelectedItem: isSelectedItem, | ||
| filterNavigatorBarLeafItem: isLastItem, | ||
| })} | ||
| title={title} | ||
| onClick={onClick ? this._onClick : null} | ||
| > | ||
| {this.props.children} | ||
| </button> | ||
| {onClick ? ( | ||
| <button type="button" className="filterNavigatorBarItemContent"> | ||
| {children} | ||
| </button> | ||
| ) : ( | ||
| <span className="filterNavigatorBarItemContent">{children}</span> | ||
| )} | ||
| </li> | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -57,22 +83,17 @@ export class FilterNavigatorBar extends React.PureComponent<Props> { | |
| classNames="filterNavigatorBarTransition" | ||
| timeout={250} | ||
| > | ||
| <li | ||
| className={classNames('filterNavigatorBarItem', { | ||
| filterNavigatorBarRootItem: i === 0, | ||
| filterNavigatorBarBeforeSelectedItem: i === selectedItem - 1, | ||
| filterNavigatorBarSelectedItem: i === selectedItem, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered removing this idea of |
||
| filterNavigatorBarLeafItem: i === items.length - 1, | ||
| })} | ||
| <FilterNavigatorBarListItem | ||
| index={i} | ||
| onClick={ | ||
| i === items.length - 1 && !uncommittedItem ? null : onPop | ||
| } | ||
| isFirstItem={i === 0} | ||
| isLastItem={i === items.length - 1} | ||
| isSelectedItem={i === selectedItem} | ||
| > | ||
| {i === items.length - 1 && !uncommittedItem ? ( | ||
| <span className="filterNavigatorBarItemContent">{item}</span> | ||
| ) : ( | ||
| <FilterNavigatorBarButton index={i} onClick={onPop}> | ||
| {item} | ||
| </FilterNavigatorBarButton> | ||
| )} | ||
| </li> | ||
| {item} | ||
| </FilterNavigatorBarListItem> | ||
| </CSSTransition> | ||
| ))} | ||
| {uncommittedItem ? ( | ||
|
|
@@ -81,18 +102,16 @@ export class FilterNavigatorBar extends React.PureComponent<Props> { | |
| classNames="filterNavigatorBarUncommittedTransition" | ||
| timeout={0} | ||
| > | ||
| <li | ||
| className={classNames( | ||
| 'filterNavigatorBarItem', | ||
| 'filterNavigatorBarLeafItem', | ||
| 'filterNavigatorBarUncommittedItem' | ||
| )} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea to move that inside the |
||
| <FilterNavigatorBarListItem | ||
| index={items.length} | ||
| isFirstItem={false} | ||
| isLastItem={true} | ||
| isSelectedItem={false} | ||
| additionalClassName="filterNavigatorBarUncommittedItem" | ||
| title={uncommittedItem} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, interesting that we are putting a title only for uncommited items, and this is exactly the same text we put inside the button as well 🤔 I feel like this is redundant (but not a blocker for this PR since this was a preexisting issue).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I wondered about that too... I believe we don't do it for other items directly currently because they're |
||
| > | ||
| <span className="filterNavigatorBarItemContent"> | ||
| {uncommittedItem} | ||
| </span> | ||
| </li> | ||
| {uncommittedItem} | ||
| </FilterNavigatorBarListItem> | ||
| </CSSTransition> | ||
| ) : null} | ||
| </TransitionGroup> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this class as it was clearly not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for removing!