Skip to content
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

fix(drawing): emit color event when color picker is opened #1315

Merged

Conversation

ChenCodes
Copy link
Contributor

Issue:
If the user updates the drawing color in the first browser tab (when there are two tabs open), the cursor color will be stale in the second tab. The proposed fix is to emit the color change event every time the Color Picker is opened - this will ensure that the cursor color matches the color in the Preview Toolbar.

Changes in this PR:

  • emit color change event whenever the Color Picker button is clicked that results in mode becoming AnnotatonMode.DRAWING
  • update unit tests

Demo:
ezgif com-gif-maker (5)

@@ -1122,6 +1122,11 @@ class BaseViewer extends EventEmitter {
this.containerEl.classList.add(className);
}
}

if (mode === AnnotationMode.DRAWING) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this condition needed or can emit it always? Do we emit this event anywhere else that can be centralized here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can emit it always.

We emit this event in handleAnnotationColorChange in DocBaseViewer and ImageViewer but I think those should be separate from this as handleAnnotationColorChange is tied to the user action of clicking on a color in the ColorPalette. The event that is emitted in BaseViewer is more so tied to the user action of when a user is clicking on the Drawing button to show the Color Picker.

@ChenCodes ChenCodes marked this pull request as ready for review January 11, 2021 23:05
@ChenCodes ChenCodes requested a review from a team as a code owner January 11, 2021 23:05
@ChenCodes ChenCodes merged commit 39bff92 into box:master Jan 12, 2021
@ChenCodes ChenCodes deleted the fix-cursor-color-not-updated-for-two-tabs branch January 12, 2021 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants