fix: Prevent image grid from blocking labeling (#3378)#9812
Open
sbatchelder wants to merge 1 commit into
Open
Conversation
👷 Deploy request for heartex-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for label-studio-docs-new-theme pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for label-studio-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for label-studio-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes a long-standing bug where adding
grid="true"to an<Image>tag makes the image impossible to annotate — click-dragging ordouble-clicking to draw a region does nothing, and rectangle labels can't be
assigned. The grid overlay was silently capturing every pointer event before it
could reach the drawing tools beneath it. The fix marks the grid layer as
non-interactive so pointer events pass through, and adds a regression test so the
grid can never re-acquire pointer capture.
Bug fix:
listening={false}to the grid ("ruler")<Layer>inImageGrid.jsxsothe grid opts out of Konva hit detection and no longer swallows the pointer
events used to draw regions and assign labels.
Test:
ImageGrid.test.jsx, a regression test that rendersImageGridandasserts the grid layer is non-interactive (
listening={false}), plus acell-count sanity check. The test fails on the unpatched component and passes
with the fix.
Fixes #3378.
Reason for change
Problem. When
grid="true"is set on an<Image>tag, users lose the abilityto annotate the image: click-drag no longer draws a region and rectangle labels
cannot be assigned. Removing
grid="true"restores normal labeling. This has beenreported by multiple community users from v1.6 onward and is still reproducible on
the current
developbranch.Minimal config that reproduces the bug:
Root cause. The grid is drawn in
ImageGrid.jsxas a Konva<Layer name="ruler">composed of one
<Rect>per grid cell, and it is rendered on top of thedrawing/regions layers. By default a Konva layer participates in hit detection
(
listeningdefaults totrue), so every pointer event lands on the grid's rectsand is consumed there instead of reaching the drawing tools below. The mouse-down
that should begin a region never arrives.
Solution. Render the ruler layer with
listening={false}. The grid is a passivevisual guide that never handles pointer events, so opting it out of hit detection
lets events pass straight through to the layers beneath, and drawing/labeling works
normally. The grid renders identically. This mirrors the approach the community
proposed in the issue thread.
The change is one line:
Screenshots / recording
The change is behavioral, not visual - the grid looks identical before and after.
The recording below shows, on an image configured with
grid="true":label can be assigned. See video here:
the grid still visible.
2026-07-08.19-36-40.mp4
Rollout strategy
No feature flag or environment variable. This is a correctness fix for an otherwise
broken configuration and is a no-op for any project that does not use
grid. Itships on by default.
Testing
Acceptance criteria (QA):
grid="true"and click-drags over theimage, then a rectangle region is drawn and the selected label is assigned — the
same as with the grid disabled.
before.
Automated tests. Added
web/libs/editor/src/components/ImageGrid/__tests__/ImageGrid.test.jsx(2 tests, both passing):
listening={false}— the regression guardthat fails if the grid ever re-acquires pointer capture.
didn't alter grid geometry.
The test mocks
react-konvasoLayer/Rectrender as inspectable DOM, avoiding areal Konva
<Stage>/canvas (the full editor MST/Konva stage isn't renderable in thejest environment; the config already skips
renderEditorintegration tests).Verified the test catches the bug. Reverting the one-line
ImageGrid.jsxchangeand re-running the suite fails the regression test with
Expected "false", Received "undefined", confirming the test is not vacuous.Risks
Reviewer notes
The fix location and approach match the community suggestion in issue #3378.
Prior community PRs #8826 and #8875 proposed the same one-line change but did not include a test and were auto-closed for inactivity; this PR adds the regression test CONTRIBUTING.md requires for bug fixes.
General notes
listeningis standard Konva/react-konva API for toggling a node's participation in hit detection;listening={false}on a layer disables it for the layer and all of its children.