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
|
@ -158,7 +158,11 @@ const getAdjustedDimensions = (
|
|||
height: number;
|
||||
baseline: number;
|
||||
} => {
|
||||
const maxWidth = element.containerId ? element.width : null;
|
||||
let maxWidth = null;
|
||||
if (element.containerId) {
|
||||
const container = Scene.getScene(element)!.getElement(element.containerId)!;
|
||||
maxWidth = container.width - BOUND_TEXT_PADDING * 2;
|
||||
}
|
||||
const {
|
||||
width: nextWidth,
|
||||
height: nextHeight,
|
||||
|
@ -246,11 +250,15 @@ export const updateTextElement = (
|
|||
originalText,
|
||||
}: { text: string; isDeleted?: boolean; originalText: string },
|
||||
|
||||
updateDimensions: boolean,
|
||||
isSubmit: boolean,
|
||||
): ExcalidrawTextElement => {
|
||||
const dimensions = updateDimensions
|
||||
? getAdjustedDimensions(element, text)
|
||||
: undefined;
|
||||
const boundToContainer = isBoundToContainer(element);
|
||||
|
||||
// Don't update dimensions and text value for bounded text unless submitted
|
||||
const dimensions =
|
||||
boundToContainer && !isSubmit
|
||||
? undefined
|
||||
: getAdjustedDimensions(element, text);
|
||||
return newElementWith(element, {
|
||||
text,
|
||||
originalText,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue