Prevent default event on icon button clicks
This commit is contained in:
parent
b3d0438537
commit
43e19f3b06
1 changed files with 19 additions and 3 deletions
|
@ -54,9 +54,25 @@ interface IconButtonProps {
|
|||
type: 'save' | 'close' | 'previous' | 'next';
|
||||
onClick?: () => void;
|
||||
}
|
||||
const IconButton = ({ onClick, type }: IconButtonProps) => (
|
||||
<a href="#" onClick={onClick} className={classNames('iconButton', type)} />
|
||||
);
|
||||
|
||||
const IconButton = ({ onClick, type }: IconButtonProps) => {
|
||||
const clickHandler = (event: React.MouseEvent<HTMLAnchorElement>): void => {
|
||||
event.preventDefault();
|
||||
if (!onClick) {
|
||||
return;
|
||||
}
|
||||
|
||||
onClick();
|
||||
};
|
||||
|
||||
return (
|
||||
<a
|
||||
href="#"
|
||||
onClick={clickHandler}
|
||||
className={classNames('iconButton', type)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export class Lightbox extends React.Component<Props, {}> {
|
||||
private containerRef: HTMLDivElement | null = null;
|
||||
|
|
Loading…
Reference in a new issue