์ผ€์ด์Šค ce-0273-caret-invisible-relative-firefox-windows-en-ko ยท ์‹œ๋‚˜๋ฆฌ์˜ค scenario-caret-invisible-relative

Text caret invisible on position:relative elements (Firefox)

OS: Windows 10/11 ๊ธฐ๊ธฐ: Desktop Any ๋ธŒ๋ผ์šฐ์ €: Firefox 120+ ํ‚ค๋ณด๋“œ: English (QWERTY) ์ดˆ์•ˆ
caretcursorcssposition-relativefirefox

ํ˜„์ƒ

In Firefox on Windows, when editing content inside an element with position:relative, the text caret is completely invisible.

์žฌํ˜„ ์˜ˆ์‹œ

  1. Create a container element with position:relative.
  2. Place contenteditable element inside it.
  3. Focus on the contenteditable element.
  4. โŒ Caret is not visible!

๊ด€์ฐฐ๋œ ๋™์ž‘

  • No visible caret: Cannot see where text will be inserted
  • Text still appears: Typed text shows up in editor
  • Difficult editing: User has to guess insertion point
  • Affects multiple browsers: Confirmed on Firefox, Safari, Chrome on macOS

์˜ˆ์ƒ ๋™์ž‘

  • Caret should be visible (blinking line or other indicator)
  • User should clearly see insertion point
  • position:relative should not affect caret rendering

์ฐธ๊ณ ์‚ฌํ•ญ ๋ฐ ๊ฐ€๋Šฅํ•œ ํ•ด๊ฒฐ ๋ฐฉํ–ฅ

  • Remove position:relative: Remove the problematic CSS property from parent
  • Use position:static: Change to static positioning
  • Move to wrapper element: Apply position:relative to wrapper, keep editor static
  • Custom caret implementation: Create blinking cursor with CSS animation

์ฝ”๋“œ ์˜ˆ์‹œ

Solution 1: Remove position:relative

.editable-container {
  position: static; /* Remove or omit position property */
}

[contenteditable] {
  min-height: 100px;
  outline: 2px solid #ddd;
}

Solution 2: Wrapper element

.wrapper {
  position: relative;
  padding: 20px;
  border: 1px solid #ccc;
}

[contenteditable] {
  position: static; /* Keep contenteditable static */
  min-height: 100px;
}

Solution 3: Custom caret

@keyframes caret-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.custom-caret {
  position: absolute;
  width: 2px;
  height: 20px;
  background: black;
  animation: caret-blink 1s infinite;
  pointer-events: none;
}
const editor = document.querySelector('[contenteditable]');
const caret = document.createElement('span');
caret.className = 'custom-caret';
document.body.appendChild(caret);

editor.addEventListener('input', (e) => {
  const selection = window.getSelection();
  if (selection.rangeCount > 0) {
    const range = selection.getRangeAt(0);
    const rect = range.getBoundingClientRect();
    
    // Update caret position
    caret.style.top = rect.top + 'px';
    caret.style.left = rect.left + 'px';
  }
});

์ด ์‹œ๋‚˜๋ฆฌ์˜ค์˜ ๋ณ€ํ˜•

์ผ€์ด์Šค OS ๋ธŒ๋ผ์šฐ์ € ์ƒํƒœ
ce-0271-caret-invisible-relative-safari-ko macOS 13+ Safari 17+ ์ดˆ์•ˆ
ce-0272-caret-invisible-relative-chrome-macos-en-ko macOS 13+ Chrome 120+ ์ดˆ์•ˆ
ce-0273-caret-invisible-relative-firefox-windows-en-ko Windows 10/11 Firefox 120+ ์ดˆ์•ˆ

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: Windows 10/11
Device: Desktop Any
Browser: Firefox 120+
Keyboard: English (QWERTY)
Your environment
Sample HTML:
Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.