new "schedule" rows should appear at top of list

Description

Clicking the "+New" button to add an additional set of dates to the list of schedules adds to the bottom of the list; it should add to the top of the list as specified in UICIRC-20 Scenario 9.

When I implemented this with unshift instead of push I found the new rows were clones of the top-most row, rather than empty rows. I have NO IDEA why.

CSP Request Details

None

CSP Rejection Details

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

John Coburn November 9, 2017 at 9:57 PM

Yep... odd combination of React's 'diff' mechanism and <Datepicker> not accounting for the occasion where an incoming value is actually blank. Fixed as .

Zak Burke November 6, 2017 at 7:31 PM

Further investigation shows this is likely related to the Datepicker component as unshift works just fine when using a TextField field instead of a Datepicker field. I'll follow up with for assistance debugging.

Mike Taylor November 6, 2017 at 12:38 PM

Then, sorry, I am out of ideas. (I don't know redux-form.)

Maybe file an issue on the package?

Zak Burke November 6, 2017 at 12:33 PM

Agreed, it looks that way, but the code is onClick={() => fields.push({})}, i.e. it's already pushing on an empty object per the example at https://redux-form.com/7.1.2/examples/fieldarrays/,

The documentation for FieldArray.push(value: Any) doesn't really tell you what's going on or how the argument is used:

Adds a value to the end of the array. Returns nothing. This is not a mutator; it dispatches an action which updates the state in Redux, which will cause your component to rerender.

I tried using a full-fledged dummy object, e.g.

but the results were the same.

Mike Taylor November 6, 2017 at 12:19 PM

Without looking at the code, this sounds like a reference-aliasing problem. Try making a shallow copy with newObject = Object.assign({}, originalObject) and see if that fixes it.

Done

Details

Assignee

Reporter

Priority

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created November 3, 2017 at 6:54 PM
Updated September 11, 2018 at 6:53 AM
Resolved November 30, 2017 at 6:39 AM
TestRail: Cases
TestRail: Runs