Closed Bug 1795904 Opened 2 years ago Closed 2 years ago

Textarea scrollHeight incorrect when dynamically added and overflow: hidden

Categories

(Core :: Layout: Scrolling and Overflow, defect)

Firefox 106
defect

Tracking

()

RESOLVED DUPLICATE of bug 1787062

People

(Reporter: knownasilya, Unassigned)

References

(Regression)

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Steps to reproduce:

Dynamically add a textarea (on button click)

  • Create it on click
  • Set overflow: 'hidden'
  • Add to body
  • Set value to something that is more then one line, e.g. '1\n2\n3\n'

Reproduction https://codepen.io/tgknownasilya/pen/wvjboOo
Code from the pen:



// Test code
function show() {
  const hiddenTextarea = document.createElement('textarea');

  hiddenTextarea.style.overflow = 'hidden';

  document.body.appendChild(hiddenTextarea);

  hiddenTextarea.value = '1\n2\n3\n';
  console.log('3 lines', { scrollHeight: hiddenTextarea.scrollHeight });

  hiddenTextarea.value = '1\n2\n3\n';
  console.log('3 line',  { scrollHeight: hiddenTextarea.scrollHeight });
}

Actual results:

Initial value causes incorrect scrollHeight. Above code snippet logs:

3 lines
Object { scrollHeight: 36 }
3 line
Object { scrollHeight: 68 }

Expected results:

Expect it to log

3 lines
Object { scrollHeight: 68 }
3 line
Object { scrollHeight: 68 }

(note that this is correct in Chrome)

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Scrolling and Overflow' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Scrolling and Overflow
Product: Firefox → Core

Note that on Firefox 103 on Linux this issue doesn't exist

Regressed by: 1778983

Note its the "Remove useless ProcessPendingRestyles call" changeset that regressed this.

:emilio, since you are the author of the regressor, bug 1778983, could you take a look? Also, could you set the severity field?

For more information, please visit auto_nag documentation.

Flags: needinfo?(emilio)

This is basically bug 1787062... It's an issue with editor initialization being async, see there. The good thing is that working around it is trivial (just add another layout-affecting getter call, like scrollHeight to flush the changes made by editor init.

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Flags: needinfo?(emilio)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.