specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
60 stars 38 forks source link

Modify ResourceSelector to use existing resource instance #4899

Closed sharadsw closed 3 weeks ago

sharadsw commented 1 month ago

Fixes #4865

When adding a form table subview, 2 resources were being created.

First one in FormTable.tsx: https://github.com/specify/specify7/blob/907d1524cfbc56380fc038b0f7a3663e7ff46576/specifyweb/frontend/js_src/lib/components/FormCells/FormTable.tsx#L458-L459

Which gets set as an expanded record and gets passed up the parent chain: https://github.com/specify/specify7/blob/907d1524cfbc56380fc038b0f7a3663e7ff46576/specifyweb/frontend/js_src/lib/components/FormCells/FormTable.tsx#L125-L132

But that resource instance gets lost in RecordSelector.tsx, which creates a new resource that does not get added to expandedRecords and gets passed all the way up to SubView.tsx https://github.com/specify/specify7/blob/907d1524cfbc56380fc038b0f7a3663e7ff46576/specifyweb/frontend/js_src/lib/components/FormSliders/RecordSelector.tsx#L128-L134

My change ensures RecordSelector uses the resource initialized by a child component.

Checklist

Testing instructions

For to-one relations:

For interactions: