-
Notifications
You must be signed in to change notification settings - Fork 30
fix(components): Hide tooltips when out of view #2894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a92d986
31920c3
b382854
eb0c2ed
24f89c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,3 +92,7 @@ | |
| font-weight: 500; | ||
| line-height: var(--typography--lineHeight-base); | ||
| } | ||
|
|
||
| .hidden { | ||
| display: none; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,59 @@ | ||
| import { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ZakaryH I updated the tooltip tests as discussed. I broke it into 2 commits:
Demo is here if you want to test while running the docs site: http://localhost:5173/visual-tests/tooltip
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Box, | ||
| Button, | ||
| Grid, | ||
| Heading, | ||
| Stack, | ||
| Text, | ||
| Tooltip, | ||
| } from "@jobber/components"; | ||
| import { Box, Button, Heading, Stack, Tooltip } from "@jobber/components"; | ||
|
|
||
| export const VisualTestTooltipPage = () => { | ||
| return ( | ||
| <Box padding="large"> | ||
| <div style={{ paddingLeft: "200px", maxWidth: "500px" }}> | ||
| <Stack gap="extravagant"> | ||
| <Heading level={3}>Tooltip Examples</Heading> | ||
| <Heading level={1}>Tooltip Examples</Heading> | ||
|
|
||
| <Stack gap="large"> | ||
| {/* Basic Tooltip */} | ||
| <section> | ||
| <Text size="large">Basic Tooltip</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <Tooltip message="This is a basic tooltip"> | ||
| <Button label="Hover me" /> | ||
| </Tooltip> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
| <Heading level={2}>Basic</Heading> | ||
| <div> | ||
| <Tooltip message="This is a basic tooltip"> | ||
| <Button label="Hover me" /> | ||
| </Tooltip> | ||
| </div> | ||
|
|
||
| {/* Tooltip Positions */} | ||
| <section> | ||
| <Text size="large">Tooltip Positions</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <Stack gap="base"> | ||
| <Tooltip message="Top tooltip" preferredPlacement="top"> | ||
| <Button label="Top" /> | ||
| </Tooltip> | ||
| <Tooltip message="Bottom tooltip" preferredPlacement="bottom"> | ||
| <Button label="Bottom" /> | ||
| </Tooltip> | ||
| <Tooltip message="Left tooltip" preferredPlacement="left"> | ||
| <Button label="Left" /> | ||
| </Tooltip> | ||
| <Tooltip message="Right tooltip" preferredPlacement="right"> | ||
| <Button label="Right" /> | ||
| </Tooltip> | ||
| </Stack> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
| <Heading level={2}>Positions</Heading> | ||
| <Stack gap="base"> | ||
| <Tooltip message="Top tooltip" preferredPlacement="top"> | ||
| <Button label="Top" /> | ||
| </Tooltip> | ||
| <Tooltip message="Bottom tooltip" preferredPlacement="bottom"> | ||
| <Button label="Bottom" /> | ||
| </Tooltip> | ||
| <Tooltip message="Left tooltip" preferredPlacement="left"> | ||
| <Button label="Left" /> | ||
| </Tooltip> | ||
| <Tooltip message="Right tooltip" preferredPlacement="right"> | ||
| <Button label="Right" /> | ||
| </Tooltip> | ||
| </Stack> | ||
|
|
||
| {/* Tooltip with Tab Index */} | ||
| <section> | ||
| <Text size="large">Tooltip with Tab Index</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <Stack gap="base"> | ||
| <Tooltip message="Default tooltip with tab index"> | ||
| <Button label="With Tab Index" /> | ||
| </Tooltip> | ||
| <Tooltip | ||
| message="Tooltip without tab index" | ||
| setTabIndex={false} | ||
| > | ||
| <Button label="Without Tab Index" /> | ||
| </Tooltip> | ||
| </Stack> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
| <Heading level={2}>Long message</Heading> | ||
| <Tooltip message="This is a very long tooltip message that demonstrates how the component handles text wrapping for longer content that might span multiple lines."> | ||
| <Button label="Long Message" /> | ||
| </Tooltip> | ||
|
|
||
| {/* Long Message Tooltip */} | ||
| <section> | ||
| <Text size="large">Long Message Tooltip</Text> | ||
| <Grid> | ||
| <Grid.Cell size={{ xs: 12, md: 6 }}> | ||
| <Tooltip message="This is a very long tooltip message that demonstrates how the component handles text wrapping for longer content that might span multiple lines."> | ||
| <Button label="Long Message" /> | ||
| </Tooltip> | ||
| </Grid.Cell> | ||
| </Grid> | ||
| </section> | ||
| <Heading level={2}>Offscreen and within scrollable container</Heading> | ||
| <div | ||
| data-testid="scrollable-container" | ||
| style={{ | ||
| height: "100px", | ||
| overflow: "scroll", | ||
| border: "1px solid", | ||
| marginBottom: "100px", | ||
| }} | ||
| > | ||
| <Box padding="large" /> | ||
| <Box padding="large" /> | ||
| <Box padding="large" /> | ||
| <Tooltip message="Offscreen tooltip"> | ||
| <Button label="Offscreen" /> | ||
| </Tooltip> | ||
| </div> | ||
| </Stack> | ||
| </Stack> | ||
| </Box> | ||
| </div> | ||
| ); | ||
| }; | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensures it's hidden from screen readers