Skip to content

Unfinished polygon locking#9554

Closed
borisheartex wants to merge 1 commit intodevelopfrom
fb-unfinished-polygon-locking-8e72
Closed

Unfinished polygon locking#9554
borisheartex wants to merge 1 commit intodevelopfrom
fb-unfinished-polygon-locking-8e72

Conversation

@borisheartex
Copy link
Copy Markdown
Contributor

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, the Edges and renderCircles (which are the only visible components of an unfinished polygon) were conditionally rendered based on !item.isReadOnly(). Locking the region sets item.isReadOnly() to true, causing these elements to stop rendering and the polygon to vanish.

Solution: Modified the rendering conditions for Edges and renderCircles to ensure they are always visible for unfinished polygons (!item.closed), regardless of the isReadOnly() 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

  • All 3304 existing unit tests passed.
  • Verified the logic change in PolygonRegion.jsx to ensure Edges and renderCircles render when !item.closed or !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.jsx on lines 629-630. The condition for rendering Edges and renderCircles was updated from !item.isReadOnly() to (!item.isReadOnly() || !item.closed). This ensures that unfinished polygons (where item.closed is false) always render their visual components, even when locked.

General notes

The Poly component, which renders the filled polygon, correctly only renders when item.closed is true, so its behavior is unchanged. The points of a locked unfinished polygon are already non-draggable due to isReadOnly(), so the locking mechanism functions as expected without further modifications.


Open in Web Open in Cursor 

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
Copy link
Copy Markdown

cursor Bot commented Mar 9, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 9, 2026

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit cc93177
🔍 Latest deploy log https://app.netlify.com/projects/heartex-docs/deploys/69aea16f64b12600081a1c60

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 9, 2026

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit cc93177
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-docs-new-theme/deploys/69aea16ff59d100008be1123

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 9, 2026

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit cc93177
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/69aea16ff0fca60008eb0c4a
😎 Deploy Preview https://deploy-preview-9554--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 9, 2026

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit cc93177
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/69aea16f305c0d0008b1ea26
😎 Deploy Preview https://deploy-preview-9554--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.62%. Comparing base (1f946dc) to head (cc93177).

❗ There is a different number of reports uploaded between BASE (1f946dc) and HEAD (cc93177). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (1f946dc) HEAD (cc93177)
pytests 1 0
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              
Flag Coverage Δ
lsf-integration 52.87% <100.00%> (-0.07%) ⬇️
lsf-unit 44.08% <0.00%> (ø)
pytests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@farioas farioas closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants