Markdown autoresize box quirky on enter
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- frontend
Research direction
Start in models/Document.bones at the updateSize function and reproduce the autoresize behavior by pressing Enter in the markdown textarea in Chrome and Firefox. Compare the textarea and clone values during keydown; done means the textarea resizes without jumping up before the new line appears.
Written by the indexing model from the issue text.
Description
When hitting enter in a markdown autoresize textarea, the textarea is not resized until the enter key is released which leads to the text jumping up one line before it drops down again. I have observed this behavior in Chrome and FF. While the browser adds the new character to the textarea, it does not make it available via .val() until the key is released.
The following code is hideous, but addresses the issue. I wonder whether there are more elegante ways around this.
diff --git a/models/Document.bones b/models/Document.bones
index 23c2044..6f5bec9 100644
--- a/models/Document.bones
+++ b/models/Document.bones
@@ -202,9 +202,14 @@ model = Backbone.Model.extend({
letterSpacing: textarea.css('letterSpacing')
}).attr('tabIndex','-1').insertBefore(textarea);
})(),
- updateSize = function() {
+ updateSize = function(ev) {
// Update clone.
- clone.val($(this).val()).scrollTop(10000);
+ var val = $(this).val();
+ On keydown, the newest character is not in .val().
+ if (ev && ev.type == 'keydown') {
+ val += String.fromCharCode(ev.keyCode);
+ }
+ clone.val(val).scrollTop(10000);
// Find scrolling height of text in clone and update
var height = clone.scrollTop();
if (!$.browser.msie) {
- Dominant language
- JavaScript
- Stars
- 4
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from developmentseed/bones-document
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
developmentseed/bones-document#6 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
developmentseed/bones-document#5 · 1 comment ·
-
Style/UI regressions Open
developmentseed/bones-document#4 · 1 assignee ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in developmentseed/bones-document
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
neondatabase/website#5944 ·
-
module: core
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
bigbluebutton/bigbluebutton#25849 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·