Skip to content
Snippets Groups Projects
Unverified Commit 58f32223 authored by Aleksandr Lesnenko's avatar Aleksandr Lesnenko Committed by GitHub
Browse files

fix core input icons tooltips (#27088)

parent 3d5ddd9c
No related branches found
No related tags found
No related merge requests found
......@@ -93,9 +93,10 @@ const Input = forwardRef(function Input(
{leftIcon && (
<Tooltip tooltip={leftIconTooltip} placement="left">
<InputLeftButton
data-testid="input-left-icon-button"
size={size}
onClick={onLeftIconClick}
disabled={!leftIconTooltip || !onLeftIconClick}
disabled={!leftIconTooltip && !onLeftIconClick}
>
<Icon name={leftIcon} />
</InputLeftButton>
......@@ -104,9 +105,10 @@ const Input = forwardRef(function Input(
{rightIcon && (
<Tooltip tooltip={rightIconTooltip} placement="right">
<InputRightButton
data-testid="input-right-icon-button"
size={size}
onClick={onRightIconClick}
disabled={!rightIconTooltip || !onRightIconClick}
disabled={!rightIconTooltip && !onRightIconClick}
>
<Icon name={rightIcon} />
</InputRightButton>
......
import React from "react";
import { render } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import Input from "./Input";
describe("Input", () => {
it("should render icon tooltips when hover them", () => {
const { getByTestId, getByText } = render(
<Input
leftIconTooltip="left tooltip"
rightIconTooltip="right tooltip"
leftIcon="search"
rightIcon="check"
/>,
);
const leftIcon = getByTestId("input-left-icon-button");
userEvent.hover(leftIcon);
expect(getByText("left tooltip")).toBeInTheDocument();
const rightIcon = getByTestId("input-right-icon-button");
userEvent.hover(rightIcon);
expect(getByText("right tooltip")).toBeInTheDocument();
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment