Skip to content

Commit

Permalink
typescript error fixes in table components
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrytovuori committed Jul 1, 2024
1 parent 1e16005 commit edc3696
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/components/table/SortableTableGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $Shape } from "utility-types";
import React, { PureComponent } from "react";
import React, { PureComponent, KeyboardEventHandler } from "react";
import classNames from "classnames";
import get from "lodash/get";
import isArray from "lodash/isArray";
Expand Down Expand Up @@ -32,7 +32,7 @@ class SortableTableGroup extends PureComponent<Props, State> {
collapse: !this.state.collapse
});
};
handleCollapseArrowIconKeyDown: (arg0: KeyboardEvent) => void = (e: any) => {
handleCollapseArrowIconKeyDown: KeyboardEventHandler<HTMLAnchorElement> = (e: any) => {
if (e.keyCode === 13) {
e.preventDefault();
this.handleCollapseArrowIconClick();
Expand Down Expand Up @@ -75,7 +75,7 @@ class SortableTableGroup extends PureComponent<Props, State> {
{showCollapseArrowColumn && <td className={classNames('collapse-arrow-column', {
'no-icon': !showCollapseArrowIcon
})}>
{ // @ts-ignore: Type '(arg0: KeyboardEvent) => void' is not assignable to type 'KeyboardEventHandler<HTMLAnchorElement>'.
{
showCollapseArrowIcon && <a className='sortable-table-row-collapse-link' onClick={this.handleCollapseArrowIconClick} onKeyDown={this.handleCollapseArrowIconKeyDown} tabIndex={0}>
<AccordionIcon className='sortable-table-row-collapse-icon' />
</a>}
Expand Down
9 changes: 4 additions & 5 deletions src/components/table/SortableTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $Shape } from "utility-types";
import React, { PureComponent } from "react";
import React, { PureComponent, KeyboardEventHandler } from "react";
import classNames from "classnames";
import get from "lodash/get";
import isArray from "lodash/isArray";
Expand Down Expand Up @@ -68,7 +68,7 @@ class SortableTableRow extends PureComponent<Props, State> {
this.isClicked = false;
clearTimeout(this.buttonPressTimer);
};
handleKeyDown: (arg0: KeyboardEvent) => void = (e: any) => {
handleKeyDown: KeyboardEventHandler<HTMLTableRowElement> = (e: any) => {
if (e.target === this.component && e.keyCode === 13) {
e.preventDefault();
this.handleRowClick();
Expand All @@ -79,7 +79,7 @@ class SortableTableRow extends PureComponent<Props, State> {
collapse: !this.state.collapse
});
};
handleCollapseArrowIconKeyDown: (arg0: KeyboardEvent) => void = (e: any) => {
handleCollapseArrowIconKeyDown: KeyboardEventHandler<HTMLAnchorElement> = (e: any) => {
if (e.keyCode === 13) {
e.preventDefault();
this.handleCollapseArrowIconClick();
Expand Down Expand Up @@ -120,7 +120,6 @@ class SortableTableRow extends PureComponent<Props, State> {
} = this.state;
const showCollapseArrowIcon = this.shouldShowCollapseArrowIcon();

// @ts-ignore: Type '(arg0: KeyboardEvent) => void' is not assignable to type 'KeyboardEventHandler<HTMLAnchorElement>'.
return <tr ref={this.setRef} id={id} tabIndex={onRowClick ? 0 : undefined} onKeyDown={this.handleKeyDown} className={classNames(className, {
'selected': isSelected
}, {
Expand All @@ -129,7 +128,7 @@ class SortableTableRow extends PureComponent<Props, State> {
{showCollapseArrowColumn && <td className={classNames('collapse-arrow-column', {
'no-icon': !showCollapseArrowIcon
})}>
{ // @ts-ignore: Type '(arg0: KeyboardEvent) => void' is not assignable to type 'KeyboardEventHandler<HTMLAnchorElement>'.
{
showCollapseArrowIcon && <a className='sortable-table-row-collapse-link' onClick={this.handleCollapseArrowIconClick} onKeyDown={this.handleCollapseArrowIconKeyDown} tabIndex={0}>
<AccordionIcon className='sortable-table-row-collapse-icon' />
</a>}
Expand Down

0 comments on commit edc3696

Please sign in to comment.