Fix className.includes bug (#3672)

This PR (should) fix a Sentry bug:
https://tldraw.sentry.io/share/issue/c4cda01be5d142b79136e8ae97a7a3a7/

### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `bugfix` — Bug fix

### Release Notes

- Fixes a rare bug effecting text shapes on mobile.
steveruizok/add-toSvg-method
Steve Ruiz 2024-05-01 11:43:27 +01:00 zatwierdzone przez GitHub
rodzic 06be91b97b
commit 9ba4f7cf2a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -105,17 +105,17 @@ export function useCanvasEvents() {
function onTouchEnd(e: React.TouchEvent) {
;(e as any).isKilled = true
// check that e.target is an HTMLElement
if (!(e.target instanceof HTMLElement)) return
if (
(e.target as HTMLElement).tagName !== 'A' &&
(e.target as HTMLElement).tagName !== 'TEXTAREA' &&
e.target.tagName !== 'A' &&
e.target.tagName !== 'TEXTAREA' &&
// When in EditingShape state, we are actually clicking on a 'DIV'
// not A/TEXTAREA element yet. So, to preserve cursor position
// for edit mode on mobile we need to not preventDefault.
// TODO: Find out if we still need this preventDefault in general though.
!(
editor.getEditingShape() &&
(e.target as HTMLElement).className.includes('tl-text-content')
)
!(editor.getEditingShape() && e.target.className.includes('tl-text-content'))
) {
preventDefault(e)
}