Skip to content
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

fix(AnalyticalTable - TypeScript): correct typing for onRowClick and accessor function #6520

Merged
merged 8 commits into from
Oct 25, 2024

Conversation

Jianrong-Yu
Copy link
Contributor

Fix #6519

Based on the code in packages/main/src/components/AnalyticalTable/hooks/useSingleRowStateSelection.ts, the type of OnRowClickEvent should be

{
  detail: { row: unknown; nativeDetail: number };
}

And the type MouseEvent should be changed to UIEvent since the event can also be a Keyboard event based on the code:

  const handleKeyDown = (e) => {
    if ((!e.target.hasAttribute('aria-expanded') || (e.shiftKey && e.code === 'Space')) && e.code === 'Enter') {
      if (
        !webComponentsReactProperties.tagNamesWhichShouldNotSelectARow.has(
          getTagNameWithoutScopingSuffix(e.target.tagName)
        )
      ) {
        e.preventDefault();
      }
      handleRowSelect(e);
    }
    if (e.code === 'Space') {
      e.preventDefault();
    }
  };

@coveralls
Copy link

coveralls commented Oct 21, 2024

Pull Request Test Coverage Report for Build 11503651671

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 87.133%

Files with Coverage Reduction New Missed Lines %
packages/main/src/components/AnalyticalTable/hooks/useKeyboardNavigation.ts 1 77.83%
Totals Coverage Status
Change from base Build 11502453799: -0.02%
Covered Lines: 5052
Relevant Lines: 5798

💛 - Coveralls

@Jianrong-Yu
Copy link
Contributor Author

I fount the type for accessor

accessor?: string | ((row: RowType, rowIndex: number) => any);`

is also incorrect,
it should be

accessor?: string | ((row: Record<string, any>, rowIndex: number) => any);

because in react-table the accessor is called with the originalRow

      if (column.accessor) {
        row.values[column.id] = column.accessor(originalRow, rowIndex, row, parentRows, data);
      } // Allow plugins to manipulate the column value

Copy link
Contributor

@Lukas742 Lukas742 left a comment

Choose a reason for hiding this comment

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

Hi @Jianrong-Yu thanks a lot for your contribution!

@Lukas742 Lukas742 changed the title fix(AnalyticalTable): fix the typing onRowClick of AnalyticalTable fix(AnalyticalTable - TypeScript): correct typing for onRowClick and accessor function Oct 23, 2024
…e the types of accessor and onRowClick

Co-authored-by: Lukas Harbarth <[email protected]>
@Jianrong-Yu
Copy link
Contributor Author

@Lukas742 Thanks for you suggestions, the code is modified now.

Copy link
Contributor

@Lukas742 Lukas742 left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

Thanks again for your contribution!

@Lukas742 Lukas742 merged commit c838d80 into SAP:main Oct 25, 2024
25 checks passed
@ui5-webcomponents-react-bot
Copy link
Contributor

🎉 This PR is included in version v2.3.3 🎉

The release is available on v2.3.3

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

[AnalyticalTable]: Typing definition is incorrect for onRowClick
4 participants