Make infinite-scroll work with <SearchAndSort>

Description

I am in the process of breaking the re-usable core of the Users module out into a smart component <SearchAndSort> – see UIU-278. At present, searching and sorting works, but infinite scroll does not. I'm instrumenting the <MultiColumnList> list code and comparing its output on ui-users's master and UIU-278 branches to figure out what's going wrong.

Environment

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Mike Taylor October 25, 2017 at 11:28 AM

I've verified that solution #1 works. Hurrah!

I think at this stage, getting into the details of a cleaner solution is not top priority. So I will file a new issue for those refinements, at a lower priority, close this one, and get back to the rest of the https://folio-org.atlassian.net/browse/UIU-278#icft=UIU-278 work that this has been blocking.

Mike Taylor October 25, 2017 at 9:11 AM

Lightbulb moment in the shower this morning.

It is true that the stripped-down <Users> component and the new <SearchAndSort> that does most of its work share the same stripes-connect resources, since they are in the same module and resources are module-wide. In that sense, <SearchAndSort> should be able to see the userCount resource that is defined and maintained by <Users>.

But they are still separate components with their own lifecycle methods. I think what's happening is that <SearchAndSort>'s first invocation of onNeedMore is working fine in incrementing the value of the userCount resource; but because this is happening in a different component from <Users>, that is not triggering a re-fetch of <Users>'s users resource, which contains the actual data.

If I am right, then there are three possible solutions, in order of difficulty and elegance.

1. Just move the userCount handling up into <Users>. That's always been an options, but one that I have resisted because it would (I think) have fixed the problem but without (I know) my ever having understood it. This would also be disappointing because it would keep more responsibility with the modules that use <SearchAndSort>, whereas the point of this exercise is to push that responsibility down the stack and make it simpler to create searching-and-sorting modules without needing to add a lot of boilerplate.

2. Have the componentWillReceiveProps lifecycle method of <Users> directly invoke that of <SearchAndSort> (or possibly delegate some other lifecycle method instead or as well – to be determined). This should force the bridge to be made between the two related resources userCount and users. Still not ideal, as it would require modules that use <SearchAndSort> to do a bit of opaque magic; but better than #1.

3. Somehow have the <SearchAndSort> component declare its interest in, and intention to change the definition of, the users resource. Somehow have stripes-connect recognise this declaration and act on it. (It may be that existing facilities relating to epics can give us what we need here, but so far I've managed to avoid having to know about them, so I don't know for sure.)

I'll start with #1, of course – if that fails, my whole sequence of inferences is cut off at the root.

Mike Taylor October 24, 2017 at 10:51 AM

And this is for the obvious reason: when we invoke <MultiColumnList>, we pass user data into it. When doing this from Users, we get the user data from the stripes-connect resource. So the problem is that the stripes-connect resource is not updating.

Mike Taylor October 23, 2017 at 9:32 PM

Ha! Very, very obvious answer: contentData.length is simply not changing. Back into <Users> to figure out how it's supposed to change, and why we're not seeing it in <SearchAndSort>.

Done

Details

Assignee

Reporter

Labels

Priority

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs
Created October 23, 2017 at 11:11 AM
Updated October 26, 2017 at 10:45 AM
Resolved October 25, 2017 at 11:41 AM
TestRail: Cases
TestRail: Runs

Flag notifications