Markdown autoresize box quirky on enter
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- frontend
调研方向
从 models/Document.bones 中的 updateSize 函数开始,在 Chrome 和 Firefox 中按下 Markdown textarea 里的 Enter,以复现 autoresize 行为。在 keydown 期间比较 textarea 和 clone 的值;当 textarea 在新行出现之前调整大小且不会向上跳动时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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) {
- 主要语言
- JavaScript
- 星标
- 4
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
developmentseed/bones-document 的其他 Issue
-
难度 5/5 一周以上 新手友好度 20/100
-
难度 4/5 3-5 天 新手友好度 25/100
developmentseed/bones-document#6 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
developmentseed/bones-document#5 · 1 条评论 ·
-
Style/UI regressions可能重新可做 @yhahn 于 5632 天前认领,目前没有进行中的 PR。 未关闭
developmentseed/bones-document#4 · 已指派 1 人 ·
-
难度 5/5 一周以上 新手友好度 30/100
查看 developmentseed/bones-document 的全部 Issue
相似的 Issue
-
Access-request approve silently discards the decider's note (decision_note written only on deny)未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
Uuriko/project-room#3378 ·
维护者通常 1 天内回复
-
Notifications pagination accepts NaN and negative LIMIT/OFFSET可能已有人在做 @Senthil455 今天认领。 未关闭BUGS MEDIUM
难度 2/5 1-3 小时 新手友好度 62/100
elixpo/blogs.elixpo#419 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 65/100
immich-app/immich#32426 ·
维护者通常 1 天内回复