UI text jumps up and down at every key

オープン 初心者向け
#26,718 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
frontend, game-dev

調査の方向性

scroll.rs の TextViewport::reveal_caret から始め、テキスト行がキャレット領域より高い場合に使われる分岐をたどってください。issue の Bevy 0.20.1 の例で再現し、入力中またはキャレットの移動中に viewport.offset.y を観察してください。行が大きすぎる場合に、オフセットが 0 と 2.4 の間で交互に変わるのではなく、中央に保たれれば完了です。

索引モデルが issue の本文から書いたものです。

説明

C-Bug S-Needs-Triage

Bevy version and features

0.20.1. Main is still affected: its scroll.rs last changed in c1b48d6, the #25948 fix.

#25305 ("Text in EditText bounces up and down for every change"), closed by #25948. That fix only adds a 0.001 tolerance, so it helps only when the line is less than 0.002 px taller than the box.

Relevant system information

Windows 10 Pro 19045, RTX 5080, Vulkan.

What you did

Run the app below, then type into the field or move the caret with the arrow keys.

The app (Bevy 0.20.1, default features)

use bevy::input_focus::AutoFocus;
use bevy::prelude::*;
use bevy::text::{EditableText, TextCursorStyle};
use bevy::ui_widgets::TextInput;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Last, log_offset)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands.spawn((
        Node {
            width: px(320),
            height: px(40),
            padding: UiRect::axes(px(10), px(6)),
            border: px(2).all(),
            margin: auto().all(),
            ..default()
        },
        BorderColor::from(Color::WHITE),
        TextInput,
        EditableText::new("Bevy"),
        TextFont {
            font_size: FontSize::Px(22.0),
            ..default()
        },
        TextCursorStyle::default(),
        AutoFocus,
    ));
}

fn log_offset(inputs: Query<&EditableText, Changed<EditableText>>) {
    for input in &inputs {
        info!("viewport.offset.y = {}", input.viewport.offset.y);
    }
}

What went wrong

The text jumps up and down at every key. The viewport.offset.y log shows 2.4, 0, 2.4, 0.

Additional information

Why it's happaing

  • The field's box inside the padding and border is 24 px high, and the 22 px font's line is 26.4 px.
  • In TextViewport::reveal_caret, a line taller than the caret area gets centered, at 1.2.
  • The next branch then snaps: back to the line's start (0) when the center is above the current offset, or to the bottom (2.4) when it's below, since there's no next line.
  • Each reveal therefore flips the offset.

A possible fix direction: when the line is taller than the caret area, keep the centered offset instead of snapping to a line.

主要言語
Rust
スター
50k
フォーク
5.1k
平均マージ
2日 20時間
マージ済み PR(30日)
129

環境構築

はじめの一歩

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

bevyengine/bevy のほかの issue

bevyengine/bevy の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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