So I have a table with an actions column and I wanted disable a dropdown item based on a reason and show a tooltip message only on that disabled element. Here are the actions and the way I tried to do that but the tooltip is rendered on all buttons from the dropdown and I want to know how to show it only on these actions disabled={unusedBlock > 0 && action.id === 1} const itemActions = [ { title: "Create", icon: <LockIcon />, id: 1 }, { title: "Delete", icon: <DeleteIcon />, id: 2 }, ];
<DropdownButton
id="dropdown-menu-align-end"
alignleft="true"
size="sm"
variant="secondary"
Tooltip="smth"
drop="left"
title={<ItemActionIcon />}
className="item-actions-dropdown display-garnishment-drop-items"
>
{itemActions.map((action) => {
return (
<OverlayTrigger overlay={<Tooltip id="tooltip-disabled">SOMETHING!</Tooltip>}>
<span className="d-inline-block">
<Dropdown.Item
key={action.title}
disabled={unusedBlock > 0 && action.id === 1}
onClick={(e) => handleOnClick(e, action.id)}
>
<div className="custom-dropdown-item">
<span className="custom-svg">{action.icon}</span>
<span>{action.title}</span>
</div>
</Dropdown.Item>
</span>
</OverlayTrigger>
);
})}
</DropdownButton>
For buttons and tooltip I used { Dropdown, DropdownButton, OverlayTrigger, Tooltip } from "react-bootstrap" and sorry for this question but I'm still a beginner.
You have to consider two things:
.
https://codesandbox.io/s/affectionate-lalande-cgiiyh