Skip to content

Conversation

yordan-st
Copy link
Contributor

@yordan-st yordan-st commented Sep 19, 2025

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

  • Added a new configuration option to show/hide selection count in the datagrid header and footer
  • Added configurable label for the clear selection button to support internationalization
  • Created a new SelectionCounter component that displays selection information
  • Improved layout and styling for better responsiveness across different screen sizes

What should be covered while testing?

  • Test different pagination options and how it looks on different viewport sizes
  • Enable / disable number of rows visibility
  • Toggle selection count to top / bottom / off
  • Change 'clear selection' text

@yordan-st yordan-st changed the title Fix/wc 3088 datagrid row selection [WC-3088] DataGrid: Row selection indicator Sep 19, 2025
@yordan-st yordan-st force-pushed the fix/wc-3088_datagrid-row-selection branch 2 times, most recently from fa68cf4 to c7622d9 Compare September 19, 2025 14:15
@yordan-st yordan-st marked this pull request as ready for review September 19, 2025 14:17
@yordan-st yordan-st requested a review from a team as a code owner September 19, 2025 14:17
@yordan-st yordan-st force-pushed the fix/wc-3088_datagrid-row-selection branch 2 times, most recently from 72b5ccc to 07c86b0 Compare September 22, 2025 09:22
@yordan-st yordan-st force-pushed the fix/wc-3088_datagrid-row-selection branch from 07c86b0 to afb73a8 Compare September 23, 2025 08:10
type WidgetTopBarProps = {
selectionCountVisibility?: SelectionCountVisibilityEnum;
clearSelectionButtonLabel?: string;
showTopBar: boolean;
Copy link
Collaborator

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 && (
Copy link
Collaborator

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} />
Copy link
Collaborator

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.

Copy link
Collaborator

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">
Copy link
Collaborator

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}
Copy link
Collaborator

@r0b1n r0b1n Sep 24, 2025

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.

Comment on lines 142 to +143
const showTopBar = paging && (pagingPosition === "top" || pagingPosition === "both");
const showFooter = paging && (pagingPosition === "bottom" || pagingPosition === "both");
Copy link
Collaborator

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 && (
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants