Skip to content

Commit d3315d2

Browse files
only21milcodexclaude
authored
fix(web): keep project name edits open during IME composition (#23231)
Co-authored-by: GPT-6.1 Sol <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 1b8516e commit d3315d2

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎apps/web/src/components/settings/ProjectSettingsPanel.browser.test.tsx‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,3 +628,36 @@ it("returns to the project overview after removal, clearing the selection but ke
628628
expect(screen.router.state.location.search).toEqual({ machine: remoteId });
629629
});
630630
});
631+
632+
describe("project name composition", () => {
633+
it.each([
634+
{ isComposing: true, keyCode: 13 },
635+
{ isComposing: false, keyCode: 229 },
636+
])("does not save a partial name for $isComposing/$keyCode", async (composition) => {
637+
setup();
638+
await using screen = await mountPanel();
639+
const input = nameInput(screen);
640+
await userEvent.fill(input, "日本");
641+
await act(async () => {
642+
input.dispatchEvent(
643+
new KeyboardEvent("keydown", { key: "Enter", bubbles: true, ...composition }),
644+
);
645+
});
646+
expect(state.update).not.toHaveBeenCalled();
647+
await expect.element(input).toHaveFocus();
648+
649+
await userEvent.type(input, "語");
650+
await userEvent.keyboard("{Enter}");
651+
await vi.waitFor(() => expect(state.update).toHaveBeenCalledTimes(2));
652+
expect(state.projects.map((project) => project.title)).toEqual(["日本語", "日本語"]);
653+
await expect.element(nameInput(screen)).toHaveValue("日本語");
654+
655+
await userEvent.fill(nameInput(screen), "日本語の名前");
656+
await userEvent.keyboard("{Tab}");
657+
await vi.waitFor(() => expect(state.update).toHaveBeenCalledTimes(4));
658+
expect(state.projects.map((project) => project.title)).toEqual([
659+
"日本語の名前",
660+
"日本語の名前",
661+
]);
662+
});
663+
});

‎apps/web/src/components/settings/ProjectSettingsPanel.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ function ProjectDetail({
464464
void renameGroup(event.currentTarget.value, wasEdited);
465465
}}
466466
onKeyDown={(event) => {
467+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
467468
if (event.key === "Enter") event.currentTarget.blur();
468469
}}
469470
/>

0 commit comments

Comments
 (0)