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

feat(region): Hide annotations if visibility is false #483

Merged
merged 3 commits into from
May 11, 2020

Conversation

mxiao6
Copy link
Contributor

@mxiao6 mxiao6 commented May 8, 2020

  • Tests

@mxiao6 mxiao6 requested a review from a team as a code owner May 8, 2020 20:45
@mxiao6 mxiao6 force-pushed the fix-visibility branch from 33bbf0d to 688b8b2 Compare May 8, 2020 21:18
@mxiao6 mxiao6 force-pushed the fix-visibility branch from 1e8348d to 36a1dfc Compare May 8, 2020 23:29
src/common/BaseAnnotator.ts Outdated Show resolved Hide resolved
src/common/BaseAnnotator.ts Outdated Show resolved Hide resolved
src/document/DocumentAnnotator.scss Outdated Show resolved Hide resolved
if (!this.rootEl) {
return;
}
if (visibility) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be handled by the parent at this point?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we're using redux to store the state, but not relying on it to hide and show the annotations, but rather rely on the value passed into setVisibility. What are your thoughts on having RegionContainer connect to this state and have RegionAnnotations use that as a basis to render RegionList?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like we're using redux to store the state, but not relying on it to hide and show the annotations, but rather rely on the value passed into setVisibility. What are your thoughts on having RegionContainer connect to this state and have RegionAnnotations use that as a basis to render RegionList?

Jared thinks this logic should live in the higher level. Otherwise we'll have to replicate this logic for all future annotation types.

src/common/BaseAnnotator.scss Outdated Show resolved Hide resolved
if (!this.rootEl) {
return;
}
if (visibility) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we're using redux to store the state, but not relying on it to hide and show the annotations, but rather rely on the value passed into setVisibility. What are your thoughts on having RegionContainer connect to this state and have RegionAnnotations use that as a basis to render RegionList?

@@ -120,7 +120,14 @@ export default class BaseAnnotator {
};

setVisibility = (visibility: boolean): void => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

isVisible

@@ -130,10 +130,10 @@ describe('BaseAnnotator', () => {
});

describe('setVisibility()', () => {
test.each([true, false])('should dispatch setVisibilityAction with visibility %p', visibility => {
test.each([true, false])('should hide/show annotations if visibility is %p', visibility => {
annotator.rootEl = defaults.container;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably just call annotator.init(1) to set up the annotator properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably just call annotator.init(1) to set up the annotator properly.

If call init but not set rootEl explicitly, eslint will throw error annotator.rootEl is possibly null

@mergify mergify bot merged commit bb13aac into box:master May 11, 2020
@mxiao6 mxiao6 deleted the fix-visibility branch August 13, 2020 00:00
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.

4 participants