Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix TextEdit hint text not following horizontal_align/vertical_align#8332

Open
thedavidweng wants to merge 2 commits into
emilk:mainemilk/egui:mainfrom
thedavidweng:fix-textedit-hint-alignmentthedavidweng/egui:fix-textedit-hint-alignmentCopy head branch name to clipboard
Open

Fix TextEdit hint text not following horizontal_align/vertical_align#8332
thedavidweng wants to merge 2 commits into
emilk:mainemilk/egui:mainfrom
thedavidweng:fix-textedit-hint-alignmentthedavidweng/egui:fix-textedit-hint-alignmentCopy head branch name to clipboard

Conversation

@thedavidweng

@thedavidweng thedavidweng commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

TextEdit hint text was always aligned to Align2::LEFT_TOP, ignoring the alignment set via TextEdit::horizontal_align / vertical_align. This caused the hint text, the cursor, and the typed text to disagree on alignment: e.g. a centered TextEdit showed a left-aligned hint with a centered cursor.

The hint text atoms now use the widget's align, so the hint matches the input text alignment. The default align is still LEFT_TOP, so multi line text edits (and the default styling) are unchanged.

Root cause

In crates/egui/src/widgets/text_edit/builder.rs, the hint-text branch hardcoded:

atoms.push_right(atom.atom_align(Align2::LEFT_TOP));

while the input-text branch used .atom_align(self.align). The hint path now uses align as well.

Drive-by: silence clippy::unnecessary_wraps in egui_kittest::app_kind

AppKind::run returns Option<egui::Response>. The Option wrap is required when the eframe feature is enabled (the Eframe branch returns None), but clippy::unnecessary_wraps fires when egui_kittest is built standalone without the eframe feature (e.g. cargo clippy -p egui_kittest). The workspace CI run doesn't hit it because feature unification via egui_demo_app enables eframe, but it's a real annoyance for anyone linting the crate on its own. Added a scoped #[cfg_attr(not(feature = "eframe"), expect(clippy::unnecessary_wraps))] with an explanatory comment.

Test plan

  • Added textedit_hint_text_should_follow_text_alignment kittest regression in crates/egui_kittest/tests/regression_tests.rs. It fails before the fix (hint_center_x=24.25 vs edit_center_x=100) and passes after.
  • cargo test -p egui
  • cargo test -p egui_kittest --all-features --test regression_tests
  • cargo clippy -p egui_kittest --all-features --test regression_tests -- -D warnings
  • RUSTFLAGS="-D warnings" cargo clippy -p egui_kittest --lib (pre-existing unnecessary_wraps now silenced)
  • cargo clippy -p egui -- -D warnings
  • cargo fmt --check

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/8332-fix-textedit-hint-alignment
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@thedavidweng
thedavidweng force-pushed the fix-textedit-hint-alignment branch from 3ca348c to 7e95948 Compare July 22, 2026 09:46
The hint text was always aligned to LEFT_TOP, ignoring the alignment set
with TextEdit::horizontal_align/vertical_align. This made the hint text,
the cursor, and the typed text disagree on alignment (e.g. a centered
TextEdit showed a left-aligned hint with a centered cursor).

Use the widget's align for the hint text atoms so the hint matches the
input text. The default align is still LEFT_TOP, so multi line text
edits are unchanged.

Also silence a pre-existing clippy::unnecessary_wraps warning in
egui_kittest::app_kind that fires when building egui_kittest without
the eframe feature (the Option wrap is required when eframe is enabled).

Closes emilk#8309.
@thedavidweng
thedavidweng force-pushed the fix-textedit-hint-alignment branch from 7e95948 to 5f758c1 Compare July 22, 2026 09:53
rustybuzz was flagged as unmaintained (RUSTSEC-2026-0206) on 2026-07-12,
after the previous deny fix (emilk#8300) was merged. It is pulled in
transitively via resvg/usvg, used by egui_extras for SVG support.

resvg cannot be bumped yet due to a tiny-skia version conflict (see
comment in Cargo.toml), and the recommended replacement (harfrust) has
not been adopted by resvg. Following the same pattern as the existing
ignored advisories (ttf-parser, quick-xml), add RUSTSEC-2026-0206 to
the ignore list until resvg can be updated.

This restores the cargo-deny CI checks to green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextEdit hint text alignment and cursor position is inconsistent with align functions

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.