Skip to content

Commit

Permalink
fix event target
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov committed Jan 21, 2025
1 parent 6a52d14 commit 4bffaa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion utils/vara-ui/src/components/tooltip/tooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta, StoryObj } from '@storybook/react';

import { Tooltip } from './tooltip';
import { Button } from '../button';

type Type = typeof Tooltip;
type Story = StoryObj<Type>;
Expand All @@ -11,7 +12,11 @@ const meta: Meta<Type> = {
args: {
position: 'top',
value: 'Tooltip',
children: <button style={{ marginLeft: '256px', marginTop: '256px' }}>Hover my insanely long text</button>,
children: (
<div style={{ maxWidth: '256px', margin: '64px auto 0' }}>
<Button text="Hover me" block />
</div>
),
},
argTypes: {
position: {
Expand Down
2 changes: 1 addition & 1 deletion utils/vara-ui/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Tooltip({ value, position = 'top', children }: Props) {
const [style, setStyle] = useState<CSSProperties>();

const handleMouseOver = (event: MouseEvent) => {
const anchor = event.target as HTMLElement | null;
const anchor = event.currentTarget as HTMLElement | null;
if (!anchor) return;

setStyle(getPosition(anchor, position));
Expand Down

0 comments on commit 4bffaa7

Please sign in to comment.