mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: don't mutate the bounded text if not updated when submitted (#4543)
* fix: don't mutate the bounded text if not updated when submitted * dont update text for bounded text unless submitted * add specs * use node 16 * fix * Update text when editing and cache prev text * update prev text when props updated * remove only * type properly and remove unnecessary type checks * cache original text and compare with editor value to fix alignement issue after editing and add specs * naming tweak Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
62bead66d7
commit
50bd5fbae1
5 changed files with 426 additions and 166 deletions
|
@ -1911,8 +1911,8 @@ class App extends React.Component<AppProps, AppState> {
|
|||
const updateElement = (
|
||||
text: string,
|
||||
originalText: string,
|
||||
isDeleted = false,
|
||||
updateDimensions = false,
|
||||
isDeleted: boolean,
|
||||
isSubmit: boolean,
|
||||
) => {
|
||||
this.scene.replaceAllElements([
|
||||
...this.scene.getElementsIncludingDeleted().map((_element) => {
|
||||
|
@ -1924,7 +1924,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
isDeleted,
|
||||
originalText,
|
||||
},
|
||||
updateDimensions,
|
||||
isSubmit,
|
||||
);
|
||||
}
|
||||
return _element;
|
||||
|
@ -1950,7 +1950,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
];
|
||||
},
|
||||
onChange: withBatchedUpdates((text) => {
|
||||
updateElement(text, text, false, !element.containerId);
|
||||
updateElement(text, text, false, false);
|
||||
if (isNonDeletedElement(element)) {
|
||||
updateBoundElements(element);
|
||||
}
|
||||
|
@ -1996,7 +1996,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
// do an initial update to re-initialize element position since we were
|
||||
// modifying element's x/y for sake of editor (case: syncing to remote)
|
||||
updateElement(element.text, element.originalText);
|
||||
updateElement(element.text, element.originalText, false, false);
|
||||
}
|
||||
|
||||
private deselectElements() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue