posit-dev / posit-dev/py-shiny

[Bug]: Caret Drift BUG repeating even after updating to ver 1.6.1

Open
#2,234 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triage:done bug needs clarification needs-triage Priority: Medium regression
Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

Component

UI (ui.*)

Severity

P1 - High (major feature broken)

Shiny Version

1.6.1

Python Version

3.11.11

Minimal Reproducible Example
from shiny import App, Inputs, Outputs, Session, render, ui


app_ui = ui.page_fillable(
    ui.layout_columns(
        ui.card(
            ui.card_header("Python Code Editor"),
            ui.input_code_editor(
                "code",
                label="Enter Python code:",
                value="def greet(name):\n    return f'Hello, {name}!'\n\nprint(greet('World'))",
                language="sql",
                height="200px",
            ),
        ),
        ui.card(
            ui.card_header("Editor Value"),
            ui.output_text_verbatim("value", placeholder=True),
        ),
        col_widths=[6, 6],
    )
)


def server(input: Inputs, output: Outputs, session: Session):
    @render.text
    def value():
        return input.code()


app = App(app_ui, server)


if __name__ == "__main__":
    app.run()
Behavior

I have noticed that the BUG has been marked as fixed for shiny 1.6.1 but after testing, it looks like it has not been properly fixed.

Current: As I'm typing on the code editor, caret drifts to the right and becomes visually separated from the actual text insertion point. Caret DOES NOT match the actual insertion point where it should be.
Expected: The caret should stay visually aligned with the true insertion point while typing, regardless of how long the current line is.

Error Messages (if any)

Environment
Windows 11
Chrome 147.0.7727.102(Official Build) (64bit)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by running the supplied minimal example and inspect the UI implementation behind input_code_editor while reproducing caret drift on a long line. Done means the caret remains visually aligned with the true insertion point during typing in the reported environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.