Skip to content

The focus on the TextEdit input is removed when typing is completed with Japanese IME #7809

@choyunjin

Description

@choyunjin

At first I clarify that the adding the lines that applies the main branch of egui to my Cargo.toml cause the following error.

error: failed to download `fearless_simd v0.3.0`

Caused by:
  unable to get packages from source

Caused by:
  failed to unpack package `fearless_simd v0.3.0`

Caused by:
  failed to iterate over archive

Caused by:
  invalid gzip header

Describe the bug

obs_2025-12-24_18-13-15.mp4

In this video, you can see the Latin alphabet (English), Hangul (Korean), and Japanese characters being typed properly. However, when Enter key is pressed after typing with Japanese IME, the focus, which should be retained even after pressing Enter, is removed from the TextEdit input in egui application.

To Reproduce

This is my main.rs code to reproduce this bug.

use std::sync::Arc;
use eframe::egui;

fn main() -> eframe::Result {
    eframe::run_native(
        "TextEdit Test",
        eframe::NativeOptions {
            viewport: egui::ViewportBuilder::default().with_inner_size(
                (640.0, 360.0)
            ),
            ..Default::default()
        },
        Box::new(|ctx| {
            init_fonts(&ctx.egui_ctx);
            Ok(Box::new(App::new()))
        })
    )
}

// replace this with the proper path of the font file that supports CJK characters.
const MAIN_FONT: &'static [u8] = include_bytes!("./NotoSansCJK-Regular.otf");

fn init_fonts(ctx: &egui::Context) {
    let mut fonts = egui::FontDefinitions::default();

    fonts.font_data.insert(
        "main-font".to_owned(),
        Arc::new(egui::FontData::from_static(MAIN_FONT))
    );

    let proportional = fonts.families.entry(egui::FontFamily::Proportional).or_default();
    proportional.insert(0, "main-font".to_owned());

    ctx.set_fonts(fonts);
}

pub struct App {
    text_content: String
}

impl App {
    pub fn new() -> Self {
        App { text_content: String::new() }
    }
}

impl eframe::App for App {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.heading("TextEdit");
            ui.text_edit_singleline(&mut self.text_content);
            egui::TextEdit::singleline(&mut self.text_content)
        });
    }
}

Expected behavior

The focus should not be removed when pressing Enter, as shown at the end of the video.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: -
  • Version: -

Smartphone (please complete the following information):

  • Device: -
  • OS: -
  • Browser: -
  • Version: -

Additional context

-

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions