-
Notifications
You must be signed in to change notification settings - Fork 55
[WC-3088] DataGrid: Row selection indicator #1907
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
base: main
Are you sure you want to change the base?
Conversation
fa68cf4
to
c7622d9
Compare
72b5ccc
to
07c86b0
Compare
07c86b0
to
afb73a8
Compare
type WidgetTopBarProps = { | ||
selectionCountVisibility?: SelectionCountVisibilityEnum; | ||
clearSelectionButtonLabel?: string; | ||
showTopBar: boolean; |
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.
This name make no sense, it is not about topBar, but about showing or not showing pagination part of it.
{props.children} | ||
<div {...restProps} className="widget-datagrid-top-bar table-header"> | ||
<div className="widget-datagrid-padding-top"> | ||
{selectionCountVisibility === "top" && selectedCount > 0 && ( |
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.
This check can be move outside of the component can receive just a boolean.
<div className="widget-datagrid-padding-top"> | ||
{selectionCountVisibility === "top" && selectedCount > 0 && ( | ||
<div className="widget-datagrid-tb-start"> | ||
<SelectionCounter clearSelectionButtonLabel={clearSelectionButtonLabel} /> |
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 think it is better to pass this same way as we pass pagination (as a prop myProperty={<MyComponent />}
). This we we don't need to pass along props that are needed for SelectionCounter
only.
Arguably pagination has to be passed along the similar way, so it does look unified.
Also maybe instead of passing booleans we can just check if prop exists, like:
{props.myProperty && <div className="widget-datagrid-tb-end">{props.myProperty}</div>}
This way if we pass null it won't render.
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.
For example: see how we pass pagination
to WidgetFooter
.
<enumerationValue key="both">Both</enumerationValue> | ||
</enumerationValues> | ||
</property> | ||
<property key="selectionCountVisibility" type="enumeration" defaultValue="bottom" required="true"> |
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.
We already have setting called pagingPosition
, which basically controls almost identical behavior but for pagination. To make it consistent I suggest naming this one somethingSomethingPosition
as well.
pageSize={props.pageSize} | ||
paginationType={props.pagination} | ||
loadMoreButtonCaption={props.loadMoreButtonCaption?.value} | ||
clearSelectionButtonLabel={props.clearSelectionButtonLabel?.value} |
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.
Maybe this one should be part of SelectionCountStore
, so <SelectionCounter />
can use it from the store, so we don't have to drill this property down through the widget.
const showTopBar = paging && (pagingPosition === "top" || pagingPosition === "both"); | ||
const showFooter = paging && (pagingPosition === "bottom" || pagingPosition === "both"); |
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.
They have to be named correctly, something like showTopBarPagination
and showFooterPagination
as after the change, pagination is not the only part that determines if the topbar/footer is shown, so the names have to be adjusted.
</div> | ||
{hasMoreItems && paginationType === "loadMore" && ( | ||
<div className="widget-datagrid-pb-middle"> | ||
{selectionCountVisibility === "bottom" && selectedCount > 0 && ( |
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.
All comments for WidgetTopBar
apply here as well.
Pull request type
Bug fix (non-breaking change which fixes an issue)
Description
What should be covered while testing?