Skip to content

Comments

Fix auto-resizing of BBCode editor text box on Firefox#4

Open
rose-blossom wants to merge 1 commit intof-list:masterfrom
rose-blossom:fix-firefox-bbcode-editor-resizing
Open

Fix auto-resizing of BBCode editor text box on Firefox#4
rose-blossom wants to merge 1 commit intof-list:masterfrom
rose-blossom:fix-firefox-bbcode-editor-resizing

Conversation

@rose-blossom
Copy link

The previous implementation strategy used getComputedStyle().cssText to copy styles from the real textarea onto the fake, invisible one used for computing sizing metrics. This worked alright on Chrome, but not on Firefox, as Firefox currently always returns an empty string for cssText on the result of getComputedStyle() (see Bugzilla #137687).

This commit avoids copying the computed styles manually in favor of just applying the same CSS classes to the invisible textarea. It also tweaks the size computation to add the border height to the computed scrollHeight before setting the inline height style, since scrollHeight does not include the border, but box-sizing is set to border-box, and the 2px difference was enough to provoke a scroll bar in Firefox.

The previous implementation strategy used getComputedStyle().cssText to
copy styles from the real textarea onto the fake, invisible one used for
computing sizing metrics. This worked alright on Chrome, but not on
Firefox, as Firefox currently always returns an empty string for cssText
on the result of getComputedStyle() (see Bugzilla #137687).

This commit avoids copying the computed styles manually in favor of just
applying the same CSS classes to the invisible textarea. It also tweaks
the size computation to add the border height to the computed
scrollHeight before setting the inline height style, since scrollHeight
does not include the border, but box-sizing is set to border-box, and
the 2px difference was enough to provoke a scroll bar in Firefox.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant