1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

resolve PR comments

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-01-27 08:25:34 -05:00
parent 86aaefdb7e
commit e7cb782d79

View File

@ -5,7 +5,7 @@
import "./icon.scss";
import React, { ReactNode } from "react";
import React, { createRef, ReactNode } from "react";
import { NavLink } from "react-router-dom";
import type { LocationDescriptor } from "history";
import { boundMethod, cssNames } from "../../utils";
@ -30,7 +30,7 @@ export interface IconProps extends React.HTMLAttributes<any>, TooltipDecoratorPr
@withTooltip
export class Icon extends React.PureComponent<IconProps> {
public ref?: HTMLElement;
private readonly ref = createRef<HTMLAnchorElement>();
static defaultProps: IconProps = {
focusable: true,
@ -60,7 +60,7 @@ export class Icon extends React.PureComponent<IconProps> {
// fallthrough
case "Enter": {
setImmediate(() => this.ref?.click());
this.ref.current?.click();
evt.preventDefault();
break;
}
@ -121,16 +121,16 @@ export class Icon extends React.PureComponent<IconProps> {
const { className, children } = iconProps;
return (
<NavLink className={className} to={link} ref={e => this.ref = e}>
<NavLink className={className} to={link} ref={this.ref}>
{children}
</NavLink>
);
}
if (href) {
return <a {...iconProps} href={href} ref={e => this.ref = e}/>;
return <a {...iconProps} href={href} ref={this.ref}/>;
}
return <i {...iconProps} ref={e => this.ref = e} />;
return <i {...iconProps} ref={this.ref} />;
}
}