Skip to content

Fix judge builder instruction textarea#21299

Merged
daniellok-db merged 1 commit intomlflow:masterfrom
daniellok-db:fix-judge-textbox
Mar 4, 2026
Merged

Fix judge builder instruction textarea#21299
daniellok-db merged 1 commit intomlflow:masterfrom
daniellok-db:fix-judge-textbox

Conversation

@daniellok-db
Copy link
Collaborator

@daniellok-db daniellok-db commented Mar 3, 2026

Related Issues/PRs

Relates to experiment scorers HighlightedTextArea component

What changes are proposed in this pull request?

Fixes a scroll desync bug in the HighlightedTextArea overlay pattern used in the LLM scorer instructions field. To repro, simply paste a lot of text in the box (enough to cause an overflow), then press enter at the end to create a newline. The two views should now be desynced and editing won't happen on the line you expect.

When the text ends in a newline, the HighlightedTextArea becomes shorter than the actual textarea used for editing. This seems to be some sort of general bug in the way pre-wrap divs handle trailing newlines.

As a workaround, add an explicit new element when the value ends in a newline to prevent this from happening

How is this PR tested?

  • Existing unit/integration tests
  • Manual tests

Before:

Screen.Recording.2026-03-03.at.3.29.42.PM.mov

After:

Screen.Recording.2026-03-03.at.3.33.33.PM.mov

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Does this PR require updating the MLflow Skills repository?

  • No. You can skip the rest of this section.
  • Yes. Please link the corresponding PR or explain how you plan to update it.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Fix scroll desync in the LLM scorer instructions textarea where the highlighted backdrop would fall out of alignment with the cursor when pressing Enter at the end of overflowing content.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Copilot AI review requested due to automatic review settings March 3, 2026 06:59
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🛠 DevTools 🛠

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/21299/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/21299/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/21299/merge

@github-actions github-actions bot added size/XS v3.10.1 area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/bug-fix Mention under Bug Fixes in Changelogs. labels Mar 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a scroll synchronization issue in the HighlightedTextArea overlay (transparent textarea over highlighted backdrop) used in experiment scorer instructions, where overflowing content could cause the backdrop and textarea to become misaligned after edits.

Changes:

  • Add a useEffect that re-syncs backdrop scroll after value updates.
  • Defer the re-sync with requestAnimationFrame to ensure the backdrop DOM reflects the latest content before copying scroll position.

Comment on lines +49 to +53
// (e.g., pressing Enter at the end of overflowing content) before React
// re-renders the backdrop with the new content.
useEffect(() => {
requestAnimationFrame(handleScroll);
}, [value, handleScroll]);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MODERATE: This new useEffect scroll re-sync behavior isn’t covered by the existing HighlightedTextArea tests. Consider adding a unit test that mocks requestAnimationFrame and asserts the backdrop scrollTop/scrollLeft are updated to match the textarea after a value change, to prevent regressions of this desync bug.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Documentation preview for db0e137 is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

Textareas render a trailing newline as a visible blank line (where the
cursor sits), but divs with white-space: pre-wrap do not — the trailing
newline is treated as invisible. This causes the backdrop's scrollHeight
to be shorter than the textarea's (by exactly one line-height), so the
two layers progressively fall out of alignment when the user presses
Enter at the end of overflowing content.

Fix by appending a space character to the backdrop content when the
value ends with a newline, forcing the pre-wrap div to render the
trailing line. Also switch the backdrop from overflow: hidden to
overflow: auto (with a hidden scrollbar) for more reliable programmatic
scroll syncing.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
@daniellok-db daniellok-db added the team-review Trigger a team review request label Mar 3, 2026
@github-actions github-actions bot requested review from WeichenXu123 and harupy March 3, 2026 07:44
@daniellok-db daniellok-db changed the title Fix HighlightedTextArea backdrop scroll desync on content overflow Fix judge builder instruction textarea Mar 3, 2026
@daniellok-db daniellok-db added this pull request to the merge queue Mar 4, 2026
Merged via the queue into mlflow:master with commit c78c418 Mar 4, 2026
32 of 34 checks passed
@daniellok-db daniellok-db deleted the fix-judge-textbox branch March 4, 2026 03:35
daniellok-db added a commit to daniellok-db/mlflow that referenced this pull request Mar 5, 2026
Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
daniellok-db added a commit to daniellok-db/mlflow that referenced this pull request Mar 5, 2026
Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
daniellok-db added a commit that referenced this pull request Mar 5, 2026
Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/bug-fix Mention under Bug Fixes in Changelogs. size/XS team-review Trigger a team review request v3.10.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants