Closed gregbelyea71 closed 4 years ago
You have to call decodeURIComponent
with the id from the location:
// Read the post_id from the location which is injected by React Router and passed to our component by react-admin automatically
const { post_id: post_id_string } = parse(props.location.search);
// ra-data-fakerest uses integers as identifiers, we need to parse the querystring
// We also must ensure we can still create a new comment without having a post_id
// from the url by returning an empty string if post_id isn't specified
const post_id = post_id_string ? decodeURIComponent(post_id_string) : '';
@djhi
I tried that previously and it made no difference.. i just put it into the sandbox and the behaviour is the same. Without hitting refresh in the browser... no dice
What you were expecting: Same behaviour as your sandbox example for "react-admin-advanced-recipes-create-a-record-related-to-the-current-one"... I expected to have a String ID with spaces still prepopulate the dropdown and have created date show up in comment... It used to work
What happened instead: Page shows up empty form, and will not populate until you hit refresh on the browser
Steps to reproduce: Changed react-admin to 2.9.7, changed your id's on first two records to strings with spaces, selected the first post, went to comments tab, selected add a new comment, nothing pre populates in Chrome until you hit refresh on browser.... I tested in Microsoft Edge and it pre-populates fine
Related code: https://codesandbox.io/s/react-admin-advanced-recipes-create-a-record-related-to-the-current-one-vrusd
Environment