react-toolkit
react-toolkit copied to clipboard
Action ignores href property
Issue and Steps to Reproduce
When using the Action component with href, it is ignored and the link is always #
Code to reproduce :
import "@axa-fr/react-toolkit-all/dist/style/af-toolkit-core.css";
import "@axa-fr/react-toolkit-all/dist/style/af-components.css";
import "@axa-fr/react-toolkit-core/dist/assets/fonts/icons/af-icons.css";
import Action from "@axa-fr/react-toolkit-action";
function App() {
return (
<div className="App">
<Action id="id" icon="link" href="https://axa.fr" target="_blank" />
</div>
);
}
Versions
2.0.0
Screenshots

Expected
The expected href is https://axa.fr
Actual
The href is #
Additional Details
It is because the Action component adds an onClick function to the ActionCore sub-component, and the behaviour in there is :
<a
{...otherProps}
className={componentClassName}
href={onClick ? '/#' : href} <----- issue is here
role={onClick ? 'button' : role}
onClick={onClick}
tabIndex={tabIndex}>
<i className={`glyphicon glyphicon-${icon}`} />
</a>
We should either not add an onClick when none is passed in props, or change that ternary in ActionCore, or even not allow href in Action if that is the desired behaviour.
- Installed packages @axa-fr/react-toolkit-action