Issue with Google Japanese IME Cursor Position in v6

Dear Team,

I am using CodeMirror v6, and I’ve encountered an issue where, when starting Japanese input on a new line, the characters being typed (IME candidates) appear at the top-left corner of the browser (coordinates 0,0). This issue occurs not only in my environment but also in the official demo and CodeSandbox.

Details of the Issue

When starting Japanese input on a new line, the input characters (IME candidates) are displayed at the top-left corner of the browser. The issue occurs in the following environment:


Environment

  • OS: macOS Sequoia 15.1 / Apple M3
  • Browser: Chrome
  • IME: Google Japanese Input
  • Framework: Next.js 14.2.4
  • Related Library Versions:
    • @codemirror/autocomplete: ^6.18.0
    • @codemirror/lang-markdown: ^6.2.5
    • @codemirror/language-data: ^6.5.1
    • @codemirror/state: ^6.4.1
    • @codemirror/view: ^6.33.0

Reproduction Links

CodeSandbox:
https://codesandbox.io/p/devbox/jwln87?file=%2Fapp%2Fpage.tsx

Official Demo:
https://codemirror.net/try/

Attempted Solutions

  • Changed the version of CodeMirror
  • Disabled all CSS
  • Migrated a working sample from CodeSandbox to my local environment
  • The issue occurs across multiple browsers (e.g., Chrome, Brave).
  • It also persists in incognito mode and with all extensions disabled.

Unfortunately, none of these attempts resolved the issue.


Reproduction Code Sample

The issue can be reproduced using the following code sample (with Next.js 14.2.4):

"use client";
import React, { useState } from "react";
import CodeMirror from "@uiw/react-codemirror";
import { markdown } from "@codemirror/lang-markdown";

export default function App() {
  const onChange = React.useCallback((value: any, viewUpdate: any) => {
    console.log("value:", value);
  }, []);
  return (
    <div className="relative overflow-visible">
      <CodeMirror
        value=""
        height="200px"
        theme="dark"
        extensions={[markdown()]}
        onChange={onChange}
      />
    </div>
  );
}

I would greatly appreciate it if you could provide any advice or suggestions on the possible cause or a solution to this issue.

Thank you for your time and support.

This is a bug in Chrome, which I thought they had fixed but apparently still exists. See also #1409 and Chrome issue #351029417.

1 Like

Temporary Solution for IME Issue and Question about Future Updates

Dear Marijn,

Thank you very much for your response and for guiding us regarding the issue with the EditContext API in Chrome. Your insights were incredibly helpful, and we have managed to temporarily resolve the IME positioning issue.

Here are the steps we took to address the issue:

We explicitly disabled the EditContext feature by adding the following code:

EditorView.EDIT_CONTEXT = false;

This adjustment forces the editor to fallback to the traditional contenteditable mode, resolving the Japanese IME input positioning issue.
With this workaround, we verified that the issue was resolved across multiple browsers and environments (e.g., Chrome, Brave, and Google Japanese Input on macOS). However, we recognize this as a temporary solution rather than a fundamental fix.

Question about Future Updates
We understand that this issue stems from Chrome’s implementation of EditContext. However, we would like to ask if there are any plans to introduce mechanisms in future Codemirror updates to mitigate this problem? For example, could Codemirror automatically disable EditContext for certain versions of Chrome or specific environments? Such a feature would greatly enhance usability for new users encountering similar issues.

Codemirror is an indispensable tool for our project, and we deeply appreciate all the effort you put into its development. Once again, thank you for your support and dedication to Codemirror’s continued improvement.

We look forward to your response.

Best regards,
Lynx