Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Markdown autoresize box quirky on enter

オープン
#8 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

developmentseed/bones-document のほかの issue

developmentseed/bones-document の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。