Skip to content

Commit

Permalink
Disabled tooltips are not focusable
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed Nov 19, 2024
1 parent 9d49403 commit 6c3d0b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/ClickableTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ClickableTooltipProps extends TooltipProps {
const ClickableTooltip = ({
children,
isFocusable = false,
isDisabled,
...rest
}: ClickableTooltipProps) => {
const label = useDisclosure();
Expand Down Expand Up @@ -48,7 +49,7 @@ const ClickableTooltip = ({
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
onClick={label.onOpen}
tabIndex={0}
tabIndex={isDisabled ? undefined : 0}
onFocus={isFocusable ? label.onOpen : undefined}
onBlur={isFocusable ? label.onClose : undefined}
_focusVisible={{
Expand Down
7 changes: 4 additions & 3 deletions src/components/InfoToolTip.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { Icon, Text, VStack } from "@chakra-ui/react";
import { Icon, Text, TooltipProps, VStack } from "@chakra-ui/react";
import { RiInformationLine } from "react-icons/ri";
import { FormattedMessage } from "react-intl";
import ClickableTooltip from "./ClickableTooltip";
import { useDeployment } from "../deployment";

export interface InfoToolTipProps {
export interface InfoToolTipProps extends Omit<TooltipProps, "children"> {
titleId: string;
descriptionId: string;
}
const InfoToolTip = ({ titleId, descriptionId }: InfoToolTipProps) => {
const InfoToolTip = ({ titleId, descriptionId, ...rest }: InfoToolTipProps) => {
const { appNameFull } = useDeployment();
return (
<ClickableTooltip
isFocusable
hasArrow
placement="right"
{...rest}
label={
<VStack textAlign="left" alignContent="left" alignItems="left" m={3}>
<Text fontWeight="bold">
Expand Down
1 change: 1 addition & 0 deletions src/components/LiveGraphPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const LiveGraphPanel = ({
<InfoToolTip
titleId="live-graph"
descriptionId="live-graph-tooltip"
isDisabled={isDisconnected}
/>
</HStack>
{isConnected && (
Expand Down

0 comments on commit 6c3d0b8

Please sign in to comment.