FeathersNumberInput text input node can be left with zero width when an unrelated node is hovered

Aperta
#26,339 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@collapsedonion ci sta già lavorando.

Dal 28/10/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
frontend

Direzione di ricerca

Start by locating the Bevy Feathers number input implementation and its UI layout tests; the issue does not name specific files. Reproduce the two side-by-side inputs and hover one, then inspect why the other input's text node gets zero width when its container has max_width but no explicit width. Done when the non-hovered input retains a visible text area and a regression test covers the layout.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-UI C-Bug D-Modest S-Ready-For-Implementation

Bevy version and features

bevy = { version = "0.20.0", features = ["bevy_feathers"] }

What you did

Two FeathersNumberInputs side by side, each in its own Baseline row inside a column inside a shared row, then hover one of them.

use bevy::{
    feathers::{
        FeathersPlugins,
        controls::{
            FeathersNumberInput, FeathersTextInput, HardLimit, NumberInputPrecision,
            NumberInputStep, NumberInputValue, SoftLimit,
        },
        dark_theme::create_dark_theme,
        theme::{ThemeBackgroundColor, UiTheme},
        tokens,
    },
    prelude::*,
    ui::ComputedNode,
};

#[derive(Component, Clone, Copy, Default)]
struct Left;
#[derive(Component, Clone, Copy, Default)]
struct Right;

#[derive(SceneComponent, Clone, Default)]
struct ReproNumberInput;

impl ReproNumberInput {
    fn scene() -> impl Scene {
        bsn! {
            @FeathersNumberInput
            Node {
                // width: px(100), // This fixes the issue
                max_width: px(100),
            }
            NumberInputValue::F32(1.0)
            NumberInputPrecision(1)
            NumberInputStep(0.1)
            SoftLimit::f32(0.1..=3.0)
            HardLimit::f32(0.1..=3.0)
        }
    }
}

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins.set(WindowPlugin {
                primary_window: Some(Window {
                    resolution: (400, 200).into(),
                    ..default()
                }),
                ..default()
            }),
            FeathersPlugins,
        ))
        .insert_resource(UiTheme(create_dark_theme()))
        .add_systems(Startup, setup)
        .add_systems(Update, drive)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn_scene_list(bsn_list! {
        Camera2d
        IsDefaultUiCamera
        --
        Node {
            width: percent(100),
            height: percent(100),
            align_items: AlignItems::Center,
            justify_content: JustifyContent::Center,
        }
        ThemeBackgroundColor(tokens::WINDOW_BG)
        Children [
            Node {
                flex_direction: FlexDirection::Column,
                justify_content: JustifyContent::FlexStart,
                flex_grow: 1.0,
                height: percent(100),
            }
            Children [
                Node {
                    flex_direction: FlexDirection::Row,
                    justify_content: JustifyContent::FlexStart,
                    align_items: AlignItems::Baseline,
                }
                Children [
                    Node {
                        width: px(18),
                        min_width: px(18),
                        height: px(18),
                    }
                    --
                    @ReproNumberInput
                    Left
                ]
            ]
            --
            Node {
                flex_direction: FlexDirection::Column,
                justify_content: JustifyContent::FlexStart,
                flex_grow: 1.0,
                height: percent(100),
            }
            Children [
                Node {
                    flex_direction: FlexDirection::Row,
                    justify_content: JustifyContent::FlexStart,
                    align_items: AlignItems::Baseline,
                }
                Children [
                    Node {
                        width: px(18),
                        min_width: px(18),
                        height: px(18),
                    }
                    --
                    @ReproNumberInput
                    Right
                ]
            ]
        ]
    });
}

fn text_node_of(
    root: Entity,
    children: &Query<&Children>,
    is_text_input: &Query<(), With<FeathersTextInput>>,
) -> Option<Entity> {
    children
        .iter_descendants(root)
        .find(|e| is_text_input.contains(*e))
}

fn text_width(
    root: Entity,
    children: &Query<&Children>,
    is_text_input: &Query<(), With<FeathersTextInput>>,
    nodes: &Query<&ComputedNode>,
) -> Option<f32> {
    let text = text_node_of(root, children, is_text_input)?;
    nodes.get(text).ok().map(|n| n.size().x)
}

fn drive(
    mut verdict: Local<bool>,
    q_left: Query<Entity, With<Left>>,
    q_right: Query<Entity, With<Right>>,
    q_children: Query<&Children>,
    q_is_text_input: Query<(), With<FeathersTextInput>>,
    q_nodes: Query<&ComputedNode>,
) {
    let Ok(left) = q_left.single() else { return };
    let Ok(right) = q_right.single() else { return };
    let left_width = text_width(left, &q_children, &q_is_text_input, &q_nodes);
    let right_width = text_width(right, &q_children, &q_is_text_input, &q_nodes);

    if right_width == Some(0.0) && left_width == Some(0.0) {
        return;
    }
    if !*verdict && (right_width == Some(0.0) || left_width == Some(0.0)) {
        info!("left text width = {left_width:?}, right text width = {right_width:?}");
        *verdict = true;
    }
}

What went wrong

The other (non-hovered) FeathersNumberInput renders as a blank grey rectangle. Its text node's ComputedNode::size().x becomes 0 while its height stays non-zero, so only the containers background shows through.

Output from the above repro when hovering over the left input:
left text width = Some(200.0), right text width = Some(0.0)

Additional information

AI was used to help reduce the reproduction to its minimal form.

Initial screenshot:

Image

Screenshot after hovering over leftmost FeathersNumberInput:

Image

Adding an explicit width: px(100) to the FeathersNumberInput Node fixes the issue.

Lingua principale
Rust
Stelle
49.7k
Fork
5k
Merge medio
3g 19h
PR unite (30g)
134

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bevyengine/bevy

Tutte le issue di bevyengine/bevy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.