mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
feat: stop autoselecting text on text edit on mobile (#8076)
This commit is contained in:
parent
860308eb27
commit
69f4cc70cb
2 changed files with 12 additions and 3 deletions
|
@ -4421,6 +4421,11 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
element,
|
element,
|
||||||
excalidrawContainer: this.excalidrawContainerRef.current,
|
excalidrawContainer: this.excalidrawContainerRef.current,
|
||||||
app: this,
|
app: this,
|
||||||
|
// when text is selected, it's hard (at least on iOS) to re-position the
|
||||||
|
// caret (i.e. deselect). There's not much use for always selecting
|
||||||
|
// the text on edit anyway (and users can select-all from contextmenu
|
||||||
|
// if needed)
|
||||||
|
autoSelect: !this.device.isTouchScreen,
|
||||||
});
|
});
|
||||||
// deselect all other elements when inserting text
|
// deselect all other elements when inserting text
|
||||||
this.deselectElements();
|
this.deselectElements();
|
||||||
|
|
|
@ -77,6 +77,7 @@ export const textWysiwyg = ({
|
||||||
canvas,
|
canvas,
|
||||||
excalidrawContainer,
|
excalidrawContainer,
|
||||||
app,
|
app,
|
||||||
|
autoSelect = true,
|
||||||
}: {
|
}: {
|
||||||
id: ExcalidrawElement["id"];
|
id: ExcalidrawElement["id"];
|
||||||
/**
|
/**
|
||||||
|
@ -92,6 +93,7 @@ export const textWysiwyg = ({
|
||||||
canvas: HTMLCanvasElement;
|
canvas: HTMLCanvasElement;
|
||||||
excalidrawContainer: HTMLDivElement | null;
|
excalidrawContainer: HTMLDivElement | null;
|
||||||
app: App;
|
app: App;
|
||||||
|
autoSelect?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const textPropertiesUpdated = (
|
const textPropertiesUpdated = (
|
||||||
updatedTextElement: ExcalidrawTextElement,
|
updatedTextElement: ExcalidrawTextElement,
|
||||||
|
@ -657,9 +659,11 @@ export const textWysiwyg = ({
|
||||||
|
|
||||||
let isDestroyed = false;
|
let isDestroyed = false;
|
||||||
|
|
||||||
// select on init (focusing is done separately inside the bindBlurEvent()
|
if (autoSelect) {
|
||||||
// because we need it to happen *after* the blur event from `pointerdown`)
|
// select on init (focusing is done separately inside the bindBlurEvent()
|
||||||
editable.select();
|
// because we need it to happen *after* the blur event from `pointerdown`)
|
||||||
|
editable.select();
|
||||||
|
}
|
||||||
bindBlurEvent();
|
bindBlurEvent();
|
||||||
|
|
||||||
// reposition wysiwyg in case of canvas is resized. Using ResizeObserver
|
// reposition wysiwyg in case of canvas is resized. Using ResizeObserver
|
||||||
|
|
Loading…
Add table
Reference in a new issue