Skip to content

Commit

Permalink
fix: Unable to select table rows (#34753)
Browse files Browse the repository at this point in the history
Fixes #34616

/ok-to-test tags="@tag.Anvil"

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Improved row selection in the table widget to ensure consistent
behavior when clicking and selecting rows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9807025998>
> Commit: 0886840
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9807025998&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> <hr>Fri, 05 Jul 2024 10:57:35 UTC
<!-- end of auto-generated comment: Cypress test results  -->

---------

Co-authored-by: Pawan Kumar <[email protected]>
  • Loading branch information
jsartisan and Pawan Kumar committed Jul 8, 2024
1 parent 4df4c4c commit b610ebd
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export function Row(props: RowType) {
(primaryColumnId && (props.row.original[primaryColumnId] as Key)) ||
props.index;

const onClickRow = () => {
const onClickRow = (e: React.MouseEvent) => {
e.stopPropagation();
triggerRowSelected();
};

const triggerRowSelected = () => {
props.row.toggleRowSelected();
selectTableRow?.(props.row);
};
Expand All @@ -59,6 +64,7 @@ export function Row(props: RowType) {
data-is-new={isAddRowInProgress && props.index === 0 ? "" : undefined}
data-rowindex={props.index}
key={key}
onClick={onClickRow}
>
{multiRowSelection && (
<CellCheckboxWrapper
Expand All @@ -70,7 +76,7 @@ export function Row(props: RowType) {
<Checkbox
excludeFromTabOrder={props.excludeFromTabOrder}
isSelected={!!isRowSelected}
onChange={onClickRow}
onChange={triggerRowSelected}
/>
</CellCheckboxWrapper>
)}
Expand Down

0 comments on commit b610ebd

Please sign in to comment.