Fix judge builder instruction textarea#21299
Conversation
🛠 DevTools 🛠
Install mlflow from this PRFor Databricks, use the following command: |
There was a problem hiding this comment.
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
useEffectthat re-syncs backdrop scroll aftervalueupdates. - Defer the re-sync with
requestAnimationFrameto ensure the backdrop DOM reflects the latest content before copying scroll position.
| // (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]); |
There was a problem hiding this comment.
🟡 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.
|
Documentation preview for db0e137 is available at: More info
|
a18a793 to
b8484d3
Compare
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>
b8484d3 to
db0e137
Compare
Signed-off-by: Daniel Lok <daniel.lok@databricks.com> Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Daniel Lok <daniel.lok@databricks.com> Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Daniel Lok <daniel.lok@databricks.com> Co-authored-by: Claude <noreply@anthropic.com>
Related Issues/PRs
Relates to experiment scorers HighlightedTextArea component
What changes are proposed in this pull request?
Fixes a scroll desync bug in the
HighlightedTextAreaoverlay 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
HighlightedTextAreabecomes shorter than the actualtextareaused for editing. This seems to be some sort of general bug in the waypre-wrapdivs 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?
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?
Does this PR require updating the MLflow Skills repository?
Release Notes
Is this a user-facing change?
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, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow 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" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?