Skip to content

Expand text areas without limits - #1871

Merged
fregante merged 8 commits into
masterfrom
fit-textareas
Mar 27, 2019
Merged

fregante merged 8 commits into
masterfrom
fit-textareas

Conversation

@fregante

@fregante fregante commented Mar 22, 2019 •

Copy link
Copy Markdown
Member

Fixes #1862 with bfred-it/fit-textarea

Test

Some of these already natively expand, but they are limited to your viewport height. This PR should never show scrollbars in comment boxes.

GH sometimes restores content to textareas without triggering an `input` event, the result is that `fit-textarea` won't actually resize the textarea, so it's best to just leave it on `focusin`
features.add({
id: 'fit-textareas',
init
});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also test on dynamic content boxes in reviews

@fregante fregante changed the title Fit textareas Expand text areas without limits Mar 22, 2019
@sindresorhus

Copy link
Copy Markdown
Member

From Travis:

[tsl] ERROR in /home/travis/build/sindresorhus/refined-github/source/features/parse-backticks.tsx(49,12)
      TS2339: Property 'isIssueList' does not exist on type '{ is404: () => boolean; is500: () => boolean; isBlame: () => boolean; isCommit: () => boolean; isCommitList: () => boolean; isCompare: () => boolean; isDashboard: () => boolean; isEnterprise: () => boolean; isGist: () => boolean; ... 39 more ...; onAjaxedPagesRaw: (callback: () => void) => Promise<...>; }'.

@fregante

Copy link
Copy Markdown
Member Author

That was a broken merge on master that's now fixed

@sindresorhus

Copy link
Copy Markdown
Member

If I press Enter about ~40 consecutive times in the comment box here and then press Backspace, the page freezes.

Comment thread readme.md Outdated
- [The PR/issues search box is wider.](https://user-images.githubusercontent.com/1402241/55069759-bceaf080-50bf-11e9-84d0-7707de2eb9e9.png)
- [A warning appears when trying to create a PR from the default branch.](https://user-images.githubusercontent.com/1402241/52543516-3ca94e00-2de5-11e9-9f80-ff8f9fe8bdc4.png)
- [A warning appears when unchecking `Allow edits from maintainers`.](https://user-images.githubusercontent.com/1402241/53151888-24101380-35ef-11e9-8d30-d6315ad97325.gif)
- [Comment boxes no longer show scroll bars (they always fit their content)`.](https://user-images.githubusercontent.com/1402241/54336211-66fd5e00-4666-11e9-9c5e-111fccab004d.gif)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not entirely true, in for example, the "Review changes" comment box, I get a scrollbar after a while, but I guess we can ignore that case for a simplified description. Just wanted to mention it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that happens, I missed it. I'll look into this and the possible freeze

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't touch that at all. The textarea was overflowing the viewport and it's in the position:fixed header, so we can't scroll along it. I excluded it to avoid any issues with it (I caused a few bugs on that very box many times already)

Comment thread readme.md Resolved
@sindresorhus

Copy link
Copy Markdown
Member

I really like this feature. Makes much more sense than scrollbars.

@fregante

fregante commented Mar 27, 2019 •

Copy link
Copy Markdown
Member Author

If I press Enter about ~40 consecutive times in the comment box here and then press Backspace, the page freezes.

Nasty bug, but it happens without RGH.

cc @lukehefson

Code gets stuck here in github-bootstrap.js

loop

@lukehefson

Copy link
Copy Markdown

If I press Enter about ~40 consecutive times in the comment box here and then press Backspace, the page freezes.

Nasty bug, but it happens without RGH.

cc @lukehefson

Hmm, I can't recreate myself. Would y'all mind dropping a note to [email protected]. They are way better at working through and debugging stuff than I am!

@fregante

fregante commented Mar 27, 2019 •

Copy link
Copy Markdown
Member Author

Hmm, I can't recreate myself

It's the regex. Notice how it increases with the .repeat():

❯ time node -e '/^(>[^\\n]\\n|\\s*\\n)*\\s*(\\+1|-1|:\\+1*|:-1*)\\s*$/m.test("\n".repeat(24))'
  0.35 real         0.33 user         0.02 sys

❯ time node -e '/^(>[^\\n]\\n|\\s*\\n)*\\s*(\\+1|-1|:\\+1*|:-1*)\\s*$/m.test("\n".repeat(25))'
  0.62 real         0.59 user         0.02 sys

❯ time node -e '/^(>[^\\n]\\n|\\s*\\n)*\\s*(\\+1|-1|:\\+1*|:-1*)\\s*$/m.test("\n".repeat(26))'
  1.15 real         1.13 user         0.02 sys

❯ time node -e '/^(>[^\\n]\\n|\\s*\\n)*\\s*(\\+1|-1|:\\+1*|:-1*)\\s*$/m.test("\n".repeat(27))'
  2.21 real         2.18 user         0.02 sys

@fregante

Copy link
Copy Markdown
Member Author

I reported it to support@

sindresorhus and others added 2 commits March 27, 2019 23:11
Co-Authored-By: bfred-it <[email protected]>
because it's in a `position:fixed` container; The scroll has to appear within the fixed element.
@fregante
fregante merged commit 06dcb0a into master Mar 27, 2019
@fregante
fregante deleted the fit-textareas branch March 27, 2019 17:13
@fregante fregante mentioned this pull request Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants