fix: jumping of text when typing single line in bound text (#5139)
* fix: jumping of text when typing single line in bound text * add comment
This commit is contained in:
parent
aae8e2fa5d
commit
b30066ca19
@ -283,7 +283,14 @@ export const textWysiwyg = ({
|
|||||||
// using scrollHeight here since we need to calculate
|
// using scrollHeight here since we need to calculate
|
||||||
// number of lines so cannot use editable.style.height
|
// number of lines so cannot use editable.style.height
|
||||||
// as that gets updated below
|
// as that gets updated below
|
||||||
const lines = editable.scrollHeight / getApproxLineHeight(font);
|
// Rounding here so that the lines calculated is more accurate in all browsers.
|
||||||
|
// The scrollHeight and approxLineHeight differs in diff browsers
|
||||||
|
// eg it gives 1.05 in firefox for handewritten small font due to which
|
||||||
|
// height gets updated as lines > 1 and leads to jumping text for first line in bound container
|
||||||
|
// hence rounding here to avoid that
|
||||||
|
const lines = Math.round(
|
||||||
|
editable.scrollHeight / getApproxLineHeight(font),
|
||||||
|
);
|
||||||
// auto increase height only when lines > 1 so its
|
// auto increase height only when lines > 1 so its
|
||||||
// measured correctly and vertically aligns for
|
// measured correctly and vertically aligns for
|
||||||
// first line as well as setting height to "auto"
|
// first line as well as setting height to "auto"
|
||||||
@ -298,7 +305,6 @@ export const textWysiwyg = ({
|
|||||||
font,
|
font,
|
||||||
container!.width,
|
container!.width,
|
||||||
).split("\n").length;
|
).split("\n").length;
|
||||||
|
|
||||||
// This is browser behaviour when setting height to "auto"
|
// This is browser behaviour when setting height to "auto"
|
||||||
// It sets the height needed for 2 lines even if actual
|
// It sets the height needed for 2 lines even if actual
|
||||||
// line count is 1 as mentioned above as well
|
// line count is 1 as mentioned above as well
|
||||||
|
Loading…
x
Reference in New Issue
Block a user