Closed
Conversation
When a polygon is in an unfinished (unclosed) state, the only visual representation is through Edges and point circles. These were gated behind !item.isReadOnly(), which returns true when a region is locked. This caused locking an unfinished polygon to make it completely invisible, since the filled Poly component only renders for closed polygons. Changed the render conditions for Edges and renderCircles to also render when the polygon is not closed, regardless of read-only state. The points are already non-draggable when isReadOnly() is true, so the polygon remains properly locked but visible. Co-authored-by: borisheartex <borisheartex@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
✅ Deploy Preview for heartex-docs canceled.
|
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
✅ Deploy Preview for label-studio-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for label-studio-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## develop #9554 +/- ##
===========================================
- Coverage 68.33% 60.62% -7.71%
===========================================
Files 1163 885 -278
Lines 69109 43831 -25278
Branches 11822 11822
===========================================
- Hits 47225 26574 -20651
+ Misses 21877 17250 -4627
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Reason for change
Problem: When a user starts drawing a polygon (PolygonLabels) but does not finish it (leaving
item.closed = false), clicking the "Lock region" button in the Regions panel causes the unfinished polygon to disappear instead of becoming locked and visible.Root Cause: In
web/libs/editor/src/regions/PolygonRegion.jsx, theEdgesandrenderCircles(which are the only visible components of an unfinished polygon) were conditionally rendered based on!item.isReadOnly(). Locking the region setsitem.isReadOnly()totrue, causing these elements to stop rendering and the polygon to vanish.Solution: Modified the rendering conditions for
EdgesandrenderCirclesto ensure they are always visible for unfinished polygons (!item.closed), regardless of theisReadOnly()state. This allows unfinished polygons to remain visible when locked, while still preventing interaction.Screenshots
No direct UI changes are introduced, but the fix ensures that an unfinished polygon, which previously disappeared when locked, now remains visible.
Rollout strategy
Standard deployment. No specific feature flags or environment variables are needed.
Testing
PolygonRegion.jsxto ensureEdgesandrenderCirclesrender when!item.closedor!item.isReadOnly().Risks
Low. The change is localized to rendering conditions and does not affect core functionality or data persistence.
Reviewer notes
The key change is in
web/libs/editor/src/regions/PolygonRegion.jsxon lines 629-630. The condition for renderingEdgesandrenderCircleswas updated from!item.isReadOnly()to(!item.isReadOnly() || !item.closed). This ensures that unfinished polygons (whereitem.closedis false) always render their visual components, even when locked.General notes
The
Polycomponent, which renders the filled polygon, correctly only renders whenitem.closedis true, so its behavior is unchanged. The points of a locked unfinished polygon are already non-draggable due toisReadOnly(), so the locking mechanism functions as expected without further modifications.