-
Notifications
You must be signed in to change notification settings - Fork 179
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
Media: Fix for loading past page 1 #2314
Conversation
Swap useIntersectionObserver to receive a root node, not a ref.
Codecov Report
@@ Coverage Diff @@
## master #2314 +/- ##
============================================
+ Coverage 66.13% 66.61% +0.47%
- Complexity 314 373 +59
============================================
Files 651 664 +13
Lines 10768 11267 +499
============================================
+ Hits 7121 7505 +384
- Misses 3647 3762 +115 |
Size Change: +6.9 kB (0%) Total Size: 837 kB
ℹ️ View Unchanged
|
@@ -30,11 +30,7 @@ function useIntersectionEffect(ref, options = {}, handler, deps = undefined) { | |||
useEffect( | |||
() => { | |||
const node = ref.current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMIIW but options.root
will always be null
here, so while fetching next page works (root=window), correct root is not taken into account. Generally I think we should use ref here, we already talked about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL, I took a suggestion from facebook/react#13029. It's not ideal because using a ref callback doesn't provide an easy way of passing that ref around, so I need to introduce another normal ref and set its "current" in the ref callback. Not super happy with this approach so happy to chat over slack about other suggestions you may have!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Extra useRef
is not an issue for me, before that you had container
, so it's the same in terms of LOC, of course we can have some kind of helper (like people do in #13029) - but not required since we don't have other places that would use it?
An issue for this bug would be good so it can be appropriately sized, tracked, and QA'ed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should include Karma tests, because this part has been broken several times, making it possible is not trivial (changes in configuration so we can have variable number of elements returned from the API?) but I think we should make it happen.
Done. |
During our standup today we identified this need as well, and we'll be adding karma tests for the media pane in the following weeks. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
After chatting with Diego, I pushed some basic test for it, PTAL @diegovar . Optionally we can make it configurable so we can test API 500/empty state. |
assets/src/edit-story/components/library/panes/media/mediaPane.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/media/karma/mediaFetching.karma.js
Outdated
Show resolved
Hide resolved
This is fantastic, thank you Marcin! I've left a couple of comments but looks great. |
assets/src/edit-story/components/library/panes/media/karma/mediaFetching.karma.js
Outdated
Show resolved
Hide resolved
assets/src/edit-story/components/library/panes/media/karma/mediaFetching.karma.js
Outdated
Show resolved
Hide resolved
@merapi could you help fix the tests here? |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After chatting with Dima tests are now fixed (throw in waitFor), all good.
This needs testing instructions in order to move forward. They're usually part of the PR template, but here it seems to have been omitted. |
Yep, leaving that to @diegovar. |
I've added testing instructions. |
Summary
Swap
useIntersectionObserver
to receive a properly updated ref.Introduced in #2069
Relevant Technical Choices
Uses an extra ref.
To-do
None.
User-facing changes
Fixes the media pane loading past page 1.
Testing Instructions
Load the story editor and scroll the media pane to load a second page. Once it loads, keep scrolling to load page 3.
Addresses #2332