Skip to content

feat(scrolling): add scroll to annotation#463

Merged
mergify[bot] merged 4 commits intobox:masterfrom
mickr:scroll-to-active-annotation
Apr 29, 2020
Merged

feat(scrolling): add scroll to annotation#463
mergify[bot] merged 4 commits intobox:masterfrom
mickr:scroll-to-active-annotation

Conversation

@mickr
Copy link
Collaborator

@mickr mickr commented Apr 28, 2020

  • trigger scroll if needed when annotation becomes active.
  • unit tests

@mickr mickr force-pushed the scroll-to-active-annotation branch from c241294 to 075f866 Compare April 28, 2020 22:30
builder.addCase(setActiveAnnotationIdAction, (state, { payload: annotationId }) => annotationId),
builder
.addCase(setActiveAnnotationIdAction, (state, { payload: annotationId }) => annotationId)
.addCase(createAnnotationAction.fulfilled, () => null),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a little counterintuitive for me at first glance. It seems like we'd want to set the new id as active. Seems like we could use a "why" comment here.

Copy link
Collaborator Author

@mickr mickr Apr 29, 2020

Choose a reason for hiding this comment

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

I've added a comment to the code, this stems from the old activeAnnotationId being set. It is a little counter-intuitive here, but was causing a bit of a race condition for the scrolling behavior. This is something we can re-visit as well when we refine the selectedAnnotation flow if it doesn't fit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This flow seems really awkward. Can we allow box-annotations to set the id here rather than relying on the Preview SDK to do it?

@mickr mickr force-pushed the scroll-to-active-annotation branch from c27db14 to 4d6beb6 Compare April 29, 2020 19:42
@mickr mickr marked this pull request as ready for review April 29, 2020 19:44
@mickr mickr requested a review from a team as a code owner April 29, 2020 19:44
* trigger scroll if needed when annotation becomes active.
* set activeAnnotationId to null on creation to prevent holding onto old annotationId
* Add test for isActive
* Update reducer test
@mickr mickr force-pushed the scroll-to-active-annotation branch from 4d6beb6 to 4d85b3f Compare April 29, 2020 21:36
builder.addCase(setActiveAnnotationIdAction, (state, { payload: annotationId }) => annotationId),
builder
.addCase(setActiveAnnotationIdAction, (state, { payload: annotationId }) => annotationId)
.addCase(createAnnotationAction.fulfilled, () => null),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This flow seems really awkward. Can we allow box-annotations to set the id here rather than relying on the Preview SDK to do it?

ConradJChan
ConradJChan previously approved these changes Apr 29, 2020
const { annotationId, children, className, isActive, onSelect = noop, ...rest } = props;
const innerRef = React.useRef<HTMLAnchorElement>(null);

React.useImperativeHandle(ref, () => innerRef.current as HTMLAnchorElement, [innerRef]);
Copy link
Contributor

Choose a reason for hiding this comment

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

is the type cast here necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The correct type wasn't getting picked up so for this didn't figure it would be a big deal to typecast it.

const getWrapper = (props = {}): ShallowWrapper => {
return shallow(
const getWrapper = (props = {}): ReactWrapper => {
return mount(
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of a full mount, would a shallow combined with wrapper.find('a').dive() work?

Copy link
Collaborator Author

@mickr mickr Apr 29, 2020

Choose a reason for hiding this comment

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

Shallow doesn't currently work with useEffect and throws hooks errors. I don't think it is a big enough reason to not just use mount.

@mergify mergify bot merged commit e4fe40c into box:master Apr 29, 2020
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