Skip to content

Commit ffdf566

Browse files
mimecuvalosteveruizokSomeHatsMitjaBezensekcursoragent
authored
a11y: add preference to show labels/tooltips (tldraw#6444)
This is to address these issues: - https://linear.app/tldraw/issue/ACC-72/add-labels-to-the-inputs - https://linear.app/tldraw/issue/ACC-4/the-light-grey-states-in-the-panel-on-the-right-side-dont-have-enough https://github.com/user-attachments/assets/3e4f68f0-1468-4e77-98d4-5a10c904ac4a <img width="952" height="1016" alt="Screenshot 2025-07-11 at 12 43 39" src="https://github.com/user-attachments/assets/e21b2ddd-513d-44db-aa4e-908a68104383" /> <img width="314" height="854" alt="Screenshot 2025-07-11 at 12 43 48" src="https://github.com/user-attachments/assets/c1442ff2-6ec5-4429-b7d7-a647868719e8" /> <img width="424" height="396" alt="Screenshot 2025-07-11 at 13 35 45" src="https://github.com/user-attachments/assets/8eb4e7dd-5dab-4091-92ba-05a189aace17" /> <img width="1090" height="236" alt="Screenshot 2025-07-11 at 13 35 59" src="https://github.com/user-attachments/assets/b93b0a9c-9f94-4040-b9c6-ebfdf16c5282" /> Focus ring for selected items: <img width="382" height="404" alt="Screenshot 2025-07-14 at 15 07 02" src="https://github.com/user-attachments/assets/451cac56-6d4b-4438-9be0-298aa5d16675" /> ### Change type - [ ] `bugfix` - [x] `improvement` - [ ] `feature` - [ ] `api` - [ ] `other` ### Release notes - a11y: add preference to show labels/tooltips ### API changes - add `showUiLabels` as a preference - add `TldrawUiTooltip` as a new component --------- Co-authored-by: Steve Ruiz <steveruizok@gmail.com> Co-authored-by: alex <alex@dytry.ch> Co-authored-by: Mitja Bezenšek <mitja.bezensek@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: alex <alex@tldraw.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: huppy-bot[bot] <128400622+huppy-bot[bot]@users.noreply.github.com> Co-authored-by: David Sheldrick <d.j.sheldrick@gmail.com> Co-authored-by: Nakul Sharma <110083584+nakul-bigpi@users.noreply.github.com>
1 parent 39bd199 commit ffdf566

37 files changed

Lines changed: 888 additions & 378 deletions

apps/dotcom/client/e2e/fixtures/Database.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const defaultUser = {
3737
isWrapMode: null,
3838
isDynamicSizeMode: null,
3939
isPasteAtCursorMode: null,
40+
showUiLabels: null,
4041
}
4142

4243
export class Database {

apps/dotcom/client/e2e/tests/sharing.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ test.describe('signed in user on someone elses file', () => {
241241
await expect(newPage.getByTestId('tla-error-icon')).not.toBeVisible()
242242
// We should also see the file in the sidebar and a guest badge icon next to it
243243
await expect(newPage.getByTestId('tla-sidebar').getByText(newName)).toBeVisible()
244-
await expect(newPage.getByTestId(`guest-badge-${newName}`).getByRole('button')).toBeVisible()
244+
await expect(newPage.getByTestId(`guest-badge-${newName}`)).toBeVisible()
245245
})
246246

247247
test('tabs work correctly', async ({ browser, sidebar, shareMenu }) => {

apps/dotcom/client/src/tla/app/TldrawApp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ export class TldrawApp {
709709
isWrapMode: restOfPreferences.isWrapMode ?? null,
710710
isDynamicSizeMode: restOfPreferences.isDynamicSizeMode ?? null,
711711
isPasteAtCursorMode: restOfPreferences.isPasteAtCursorMode ?? null,
712+
showUiLabels: restOfPreferences.showUiLabels ?? null,
712713
})
713714
if (didCreate) {
714715
opts.trackEvent('create-user', { source: 'app' })

apps/dotcom/client/src/tla/components/TlaSidebar/components/TlaSidebarFileLink.tsx

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { KeyboardEvent, MouseEvent, useCallback, useEffect, useRef, useState } f
55
import { Link, useNavigate, useParams } from 'react-router-dom'
66
import {
77
TldrawUiMenuContextProvider,
8+
TldrawUiTooltip,
89
preventDefault,
9-
useContainer,
1010
useMenuIsOpen,
1111
useValue,
1212
} from 'tldraw'
@@ -20,13 +20,6 @@ import { F, defineMessages, useIntl } from '../../../utils/i18n'
2020
import { toggleMobileSidebar, useIsSidebarOpenMobile } from '../../../utils/local-session-state'
2121
import { FileItems, FileItemsWrapper } from '../../TlaFileMenu/TlaFileMenu'
2222
import { TlaIcon } from '../../TlaIcon/TlaIcon'
23-
import {
24-
TlaTooltipArrow,
25-
TlaTooltipContent,
26-
TlaTooltipPortal,
27-
TlaTooltipRoot,
28-
TlaTooltipTrigger,
29-
} from '../../TlaTooltip/TlaTooltip'
3023
import styles from '../sidebar.module.css'
3124
import { TlaSidebarFileLinkMenu } from './TlaSidebarFileLinkMenu'
3225
import { TlaSidebarRenameInline } from './TlaSidebarRenameInline'
@@ -213,7 +206,6 @@ export function TlaSidebarFileLinkInner({
213206
}
214207

215208
function GuestBadge({ file, href }: { file: TlaFile; href: string }) {
216-
const container = useContainer()
217209
const ownerName = file.ownerName.trim()
218210
const testId = `guest-badge-${file.name}`
219211
const navigate = useNavigate()
@@ -232,29 +224,26 @@ function GuestBadge({ file, href }: { file: TlaFile; href: string }) {
232224

233225
return (
234226
<div className={styles.sidebarFileListItemGuestBadge} data-testid={testId}>
235-
<TlaTooltipRoot disableHoverableContent>
236-
<TlaTooltipTrigger
227+
<TldrawUiTooltip
228+
content={
229+
<>
230+
{ownerName ? (
231+
<F defaultMessage={`Shared by {ownerName}`} values={{ ownerName }} />
232+
) : (
233+
<F defaultMessage="Shared with you" />
234+
)}
235+
</>
236+
}
237+
>
238+
<div
237239
dir="ltr"
238240
// this is needed to prevent the tooltip from closing when clicking the badge
239241
onClick={handleToolTipClick}
240242
className={styles.sidebarFileListItemGuestBadgeTrigger}
241243
>
242244
<TlaIcon icon="group" className="tlui-guest-icon" />
243-
</TlaTooltipTrigger>
244-
<TlaTooltipPortal container={container}>
245-
<TlaTooltipContent
246-
// this is also needed to prevent the tooltip from closing when clicking the badge
247-
onPointerDownOutside={preventDefault}
248-
>
249-
{ownerName ? (
250-
<F defaultMessage={`Shared by {ownerName}`} values={{ ownerName }} />
251-
) : (
252-
<F defaultMessage="Shared with you" />
253-
)}
254-
<TlaTooltipArrow />
255-
</TlaTooltipContent>
256-
</TlaTooltipPortal>
257-
</TlaTooltipRoot>
245+
</div>
246+
</TldrawUiTooltip>
258247
</div>
259248
)
260249
}

apps/dotcom/client/src/tla/components/TlaTooltip/TlaTooltip.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

apps/dotcom/client/src/tla/components/TlaTooltip/tooltip.module.css

Lines changed: 0 additions & 29 deletions
This file was deleted.

apps/dotcom/client/src/tla/components/tla-menu/tla-menu.tsx

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ import {
1010
useEffect,
1111
useState,
1212
} from 'react'
13-
import { TldrawUiButton, TldrawUiIcon } from 'tldraw'
13+
import { TldrawUiButton, TldrawUiIcon, TldrawUiTooltip } from 'tldraw'
1414
import { defineMessages, useMsg } from '../../utils/i18n'
1515
import { TlaIcon } from '../TlaIcon/TlaIcon'
16-
import {
17-
TlaTooltipArrow,
18-
TlaTooltipContent,
19-
TlaTooltipPortal,
20-
TlaTooltipRoot,
21-
TlaTooltipTrigger,
22-
} from '../TlaTooltip/TlaTooltip'
2316
import styles from './menu.module.css'
2417

2518
const messages = defineMessages({
@@ -59,30 +52,22 @@ export function TlaMenuControlInfoTooltip({
5952

6053
return (
6154
<div className={styles.menuInfoTriggerContainer}>
62-
<TlaTooltipRoot>
63-
<TlaTooltipTrigger dir="ltr" asChild>
64-
{href ? (
65-
<a
66-
onClick={onClick}
67-
href={href}
68-
target="_blank nofollow noreferrer"
69-
className={styles.menuInfoTrigger}
70-
>
71-
<TldrawUiIcon label={helpMsg} icon="help-circle" small />
72-
</a>
73-
) : (
74-
<TldrawUiButton type="icon" className={styles.menuInfoTrigger}>
75-
<TldrawUiIcon label={helpMsg} icon="help-circle" small />
76-
</TldrawUiButton>
77-
)}
78-
</TlaTooltipTrigger>
79-
<TlaTooltipPortal>
80-
<TlaTooltipContent>
81-
{children}
82-
<TlaTooltipArrow />
83-
</TlaTooltipContent>
84-
</TlaTooltipPortal>
85-
</TlaTooltipRoot>
55+
<TldrawUiTooltip content={children}>
56+
{href ? (
57+
<a
58+
onClick={onClick}
59+
href={href}
60+
target="_blank nofollow noreferrer"
61+
className={styles.menuInfoTrigger}
62+
>
63+
<TldrawUiIcon label={helpMsg} icon="help-circle" small />
64+
</a>
65+
) : (
66+
<TldrawUiButton type="icon" className={styles.menuInfoTrigger}>
67+
<TldrawUiIcon label={helpMsg} icon="help-circle" small />
68+
</TldrawUiButton>
69+
)}
70+
</TldrawUiTooltip>
8671
</div>
8772
)
8873
}

0 commit comments

Comments
 (0)