Skip to content

Commit

Permalink
Revert "Fix typing of default tooltip formatter (recharts#2924)"
Browse files Browse the repository at this point in the history
This reverts commit da6b9e2.
  • Loading branch information
furrycatherder committed Dec 4, 2022
1 parent c13ead6 commit fc90bde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/component/DefaultTooltipContent.tsx
Expand Up @@ -6,8 +6,8 @@ import React, { PureComponent, CSSProperties, ReactNode } from 'react';
import classNames from 'classnames';
import { isNumOrStr } from '../util/DataUtils';

function defaultFormatter<TValue extends ValueType>(value: TValue) {
return _.isArray(value) && isNumOrStr(value[0]) && isNumOrStr(value[1]) ? (value.join(' ~ ') as TValue) : value;
function defaultFormatter<T>(value: T) {
return _.isArray(value) && isNumOrStr(value[0]) && isNumOrStr(value[1]) ? value.join(' ~ ') : value;
}

export type TooltipType = 'none';
Expand All @@ -19,7 +19,7 @@ export type Formatter<TValue extends ValueType, TName extends NameType> = (
item: Payload<TValue, TName>,
index: number,
payload: Array<Payload<TValue, TName>>,
) => [TValue, TName] | TValue;
) => [ReactNode, ReactNode] | ReactNode;

export interface Payload<TValue extends ValueType, TName extends NameType> {
type?: TooltipType;
Expand Down Expand Up @@ -82,7 +82,7 @@ export class DefaultTooltipContent<TValue extends ValueType, TName extends NameT
if (finalFormatter && value != null && name != null) {
const formatted = finalFormatter(value, name, entry, i, payload);
if (Array.isArray(formatted)) {
[value, name] = formatted as [TValue, TName];
[value, name] = formatted;
} else {
value = formatted;
}
Expand Down
6 changes: 1 addition & 5 deletions src/component/Tooltip.tsx
Expand Up @@ -258,12 +258,8 @@ export class Tooltip<TValue extends ValueType, TName extends NameType> extends P
});

return (
// ESLint is disabled to allow listening to the `Escape` key. Refer to
// https://github.com/recharts/recharts/pull/2925
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<div
tabIndex={-1}
role="dialog"
tabIndex={0}
onKeyDown={event => {
if (event.key === 'Escape') {
this.setState({
Expand Down

0 comments on commit fc90bde

Please sign in to comment.