[WEB-1073] fix: Kanban dnd to work as tested on Chrome, Safari and Firefox (#4301)
* fix Kanban dnd to work as tested on Chrome Safari and Firefox * fix edge cases * revert back unintentional change
This commit is contained in:
parent
e75947a5f4
commit
6ac3cb9b31
2 changed files with 37 additions and 30 deletions
|
|
@ -6,10 +6,11 @@ export type TControlLink = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|||
children: React.ReactNode;
|
||||
target?: string;
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export const ControlLink: React.FC<TControlLink> = (props) => {
|
||||
const { href, onClick, children, target = "_self", disabled = false, ...rest } = props;
|
||||
export const ControlLink = React.forwardRef<HTMLAnchorElement, TControlLink>((props, ref) => {
|
||||
const { href, onClick, children, target = "_self", disabled = false, className, ...rest } = props;
|
||||
const LEFT_CLICK_EVENT_CODE = 0;
|
||||
|
||||
const handleOnClick = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||
|
|
@ -20,11 +21,20 @@ export const ControlLink: React.FC<TControlLink> = (props) => {
|
|||
}
|
||||
};
|
||||
|
||||
// if disabled but still has a ref or a className then it has to be rendered without a href
|
||||
if (disabled && (ref || className))
|
||||
return (
|
||||
<a ref={ref} className={className}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
|
||||
// else if just disabled return without the parent wrapper
|
||||
if (disabled) return <>{children}</>;
|
||||
|
||||
return (
|
||||
<a href={href} target={target} onClick={handleOnClick} {...rest}>
|
||||
<a href={href} target={target} onClick={handleOnClick} {...rest} ref={ref} className={className}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue