SAP / ui5-webcomponents-react

A wrapper implementation for React of the UI5 Web Components that are compliant with the SAP Fiori User Experience
https://sap.github.io/ui5-webcomponents-react/
Apache License 2.0
452 stars 101 forks source link

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

Closed Jianrong-Yu closed 1 month ago

Jianrong-Yu commented 1 month ago

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 commented 1 month ago

Pull Request Test Coverage Report for Build 11503651671

Details


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

💛 - Coveralls
Jianrong-Yu commented 1 month ago

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
Jianrong-Yu commented 1 month ago

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

ui5-webcomponents-react-bot commented 4 weeks ago

:tada: This PR is included in version v2.3.3 :tada:

The release is available on v2.3.3

Your semantic-release bot :package::rocket: