Skip to content

fix: OPTIC-2148: Icons in the circles under pre-annotation regions are missing #7506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

ricardoantoniocm
Copy link
Contributor

@ricardoantoniocm ricardoantoniocm commented May 9, 2025

Reason for change

The checkmark and cross icons on the preannotation circles were not displaying correctly. Additionally, the colors of the Accept and Reject buttons were not aligned with the new branding guidelines. This PR addresses both of these issues to improve the visual consistency and user experience.

This PR also introduces a smoother transition animation to the hover state of the buttons as well as displaying the pointer cursor when hovering them.

Screenshots

  • Before:
image image image
  • After:
image image image

Rollout strategy

No specific rollout strategy is required for this visual fix. The changes will be deployed with the next release.

Testing

  1. Log in to the LSO application in the specified environment.
  2. Navigate to a project with a connected model and interactive preannotations enabled (as per the preconditions).
  3. Open a task and ensure a preannotation is displayed for a selected label.
  4. Hover over the circles under the preannotation region.
  5. Verify that the left circle now displays a white cross on a red background (Reject).
  6. Verify that the right circle now displays a white checkmark on a green background (Accept).
  7. Confirm that the Accept and Reject buttons in the preannotation interface reflect the new branding colors.

Risks

Low. This PR primarily involves visual corrections and should not introduce any functional regressions.

Reviewer notes

  • Please pay close attention to the correct rendering of the icons and the updated button colors.
  • Ensure that the changes are consistent across different browsers if possible.

General notes

  • The color adjustments for the Accept and Reject buttons were made to align with the latest branding specifications.
  • The fix ensures that users can clearly distinguish between the accept and reject actions for preannotations through both color and iconography.

Copy link

netlify bot commented May 9, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit b3ec229
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-storybook/deploys/6824a962267b4200084428c1
😎 Deploy Preview https://deploy-preview-7506--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 site configuration.

Copy link

netlify bot commented May 9, 2025

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit b3ec229
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/6824a96268a156000801fcaf

Copy link

netlify bot commented May 9, 2025

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

Name Link
🔨 Latest commit b3ec229
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/6824a9624002fa000816b7db

Comment on lines +76 to +84
fill="#CC5E46"
iconColor="#FFFFFF"
icon={IconCross}
/>
<ControlButton
x={32}
onClick={() => item.annotation.acceptSuggestion(item.id)}
fill="#98C84E"
iconColor="#fff"
fill="#287A72"
iconColor="#FFFFFF"
Copy link
Contributor

Choose a reason for hiding this comment

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

these colors will be the same for light and darkmode, is that intended? if we need separate colors we can look at getCurrentTheme() from web/libs/ui/src/lib/ThemeToggle/ThemeToggle.tsx

Copy link
Collaborator

Choose a reason for hiding this comment

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

and can we use css vars here?

Copy link
Contributor

Choose a reason for hiding this comment

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

dug into it a little, css var probably wont work because fill gets passed into a Konva Circle component

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried CSS vars, it didn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yyassi-heartex the colors look ok on both Light and Dark Mode even though we aren't using the correct vars.

That said, this will need more work because the icons themselves aren't visible and it seems they had not been visible for some time (issue seems unrelated to recent work). The above fix by Brandon unfortunately didn't address the issue.

@hlomzik is this something you could help us look into?

Copy link
Contributor

Choose a reason for hiding this comment

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

@hlomzik The problem here is simple, though the solution may not be.

The icons never were able to be rendered previously, because it was always requiring an image to be used for canvas, but our icons have always been SVG components through SVGR. So that means this never worked, because the resulting icons for as long as I have been here have been handled through SVGR, and would produce an SVG React component, not a base64 url or url to an svg.

Now, the solution here I would say we can't entertain as is, because it involves using React Server Rendering utilities which I am still surprised it even works on the client like this to be honest. As to what else could we do here, maybe have a special import of the svg which produces a url to the asset instead of a component with the svg inside, that might be a simpler approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the guidance @bmartel . I'll try that approach.

Copy link
Collaborator

Choose a reason for hiding this comment

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

these icons were definitely working at some point...
I see 2 options:

  • to modify imports as you mentioned to get the path to svg and add it via Konva.Image. doesn't SVGR allow to get the path or stringified svg?
  • to recreate this panel in a real svg, this might be more complicated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave this as unresolved for the time being. It's a low priority fix in any case.

In short, I was not successful in applying the recommended approach (removing React Server Rendering and attempting to pull icons as URLs) after many prompt iterations. Happy to jump back to it with some help.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, that's not a styling issue anymore, it requires some subtle but fundamential changes

@ricardoantoniocm ricardoantoniocm self-assigned this May 13, 2025
Copy link
Contributor

@Copilot 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

This PR fixes the missing icons in the preannotation circles and updates the button colors to match the new branding guidelines, while also introducing a smoother hover state transition.

  • Update icon source location and colors for Accept/Reject buttons
  • Introduce hover animations and update cursor behavior
  • Add polyfills for TextEncoder/TextDecoder in Jest

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
web/libs/editor/src/components/ImageView/SuggestionControls.jsx Updated icon imports, colors, and hover animations in the SuggestionControls component
web/libs/editor/jest.setup.js Added polyfills for TextEncoder and TextDecoder for Jest

@@ -100,10 +102,13 @@ export const SuggestionControls = observer(({ item, useLayer }) => {

const ControlButton = ({ x = 0, fill, iconColor, onClick, icon }) => {
const [img, setImg] = useState(new window.Image());
const imageSize = 16;
const imageSize = 20;
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The intrinsic icon dimensions are set to 12 (in useEffect) while the displayed image size is 20. Consider aligning these dimensions to avoid potential scaling artifacts.

Copilot uses AI. Check for mistakes.


const iconElement = React.createElement(icon, { color: iconColor, width: 12, height: 12 });
const svgString = ReactDOMServer.renderToStaticMarkup(iconElement);
const base64 = btoa(unescape(encodeURIComponent(svgString)));
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

The use of 'unescape' is discouraged as it is deprecated. Consider using an alternative method for handling Unicode characters when encoding the SVG to base64.

Suggested change
const base64 = btoa(unescape(encodeURIComponent(svgString)));
const base64 = btoa(decodeURIComponent(encodeURIComponent(svgString)));

Copilot uses AI. Check for mistakes.

…0. Using decodeURIComponent instead of unescape.
Comment on lines +76 to +84
fill="#CC5E46"
iconColor="#FFFFFF"
icon={IconCross}
/>
<ControlButton
x={32}
onClick={() => item.annotation.acceptSuggestion(item.id)}
fill="#98C84E"
iconColor="#fff"
fill="#287A72"
iconColor="#FFFFFF"
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh holy moly... what is this...
that's not funky, that's scary a little. we should really improve our cursor rules to stick to tools we already have.

…into fb-optic-2148/icons-in-the-circles-under-preannotation-regions-are-missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants