{"action":"created","issue":{"url":"https://api.github.com/repos/marmelab/admin-on-rest/issues/1740","repository_url":"https://api.github.com/repos/marmelab/admin-on-rest","labels_url":"https://api.github.com/repos/marmelab/admin-on-rest/issues/1740/labels{/name}","comments_url":"https://api.github.com/repos/marmelab/admin-on-rest/issues/1740/comments","events_url":"https://api.github.com/repos/marmelab/admin-on-rest/issues/1740/events","html_url":"https://github.com/marmelab/admin-on-rest/issues/1740","id":313668143,"number":1740,"title":"Bug with DateInput filters and default value","user":{"login":"macrel","id":11870755,"avatar_url":"https://avatars3.githubusercontent.com/u/11870755?v=4","gravatar_id":"","url":"https://api.github.com/users/macrel","html_url":"https://github.com/macrel","followers_url":"https://api.github.com/users/macrel/followers","following_url":"https://api.github.com/users/macrel/following{/other_user}","gists_url":"https://api.github.com/users/macrel/gists{/gist_id}","starred_url":"https://api.github.com/users/macrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macrel/subscriptions","organizations_url":"https://api.github.com/users/macrel/orgs","repos_url":"https://api.github.com/users/macrel/repos","events_url":"https://api.github.com/users/macrel/events{/privacy}","received_events_url":"https://api.github.com/users/macrel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-12T10:31:16Z","updated_at":"2018-04-12T11:33:41Z","closed_at":null,"author_association":"NONE","body":"First off, I love admin-on-rest! I created an awesome administrative portal for our REST API in no-time, so huge thanks to you guys!\r\n\r\nI have one issue however I can't find a workaround for. I want to have this:\r\n\r\n- A date filter that is always visiable (alwaysOn), so user don't have to click 'add filter' first\r\n- The filter must have a default value (some date value, for example current date like this: new Date()\r\n- The user must be able to change the filter value (that's why I use 'filters' and not the permanent 'filter' on the grid)\r\n\r\nSo, I created a a simple grid, showing a count for a certain subject with 2 date filters: \r\n\r\n`\r\n\r\n    const GridFilters = (props) => (<Filter {...props}>\r\n\r\n\t\t<DateInput source=\"to_date\" label=\"To date\" alwaysOn options={{\r\n\t\t\t\tmode: \"portrait\",\r\n\t\t\t\tlocale: \"nl\"\r\n\t\t\t}} />\t\t\r\n\t\r\n\t\t<DateInput source=\"initialfilter_from_date\" label=\"From date\" defaultValue={props.date} alwaysOn options={{\r\n\t\t\t\tmode: \"portrait\",\r\n\t\t\t\tlocale: 'nl',\r\n\t\t\t\tdefaultDate: props.date,\r\n\t\t\t}} />\t\t\t\t\t\r\n    </Filter>);\r\n    <List title=\"Dategrid\" perPage={50} filters={<GridFilters date={new Date()} />} {...props}>\r\n        <Datagrid >\r\n           <TextField source=\"subject\" />\r\n           <NumberField source=\"count\" />\r\n\t</Datagrid>\r\n</List>`\r\n\r\nMy app has a custom menu with multiple pages. If I directly go to the url that this page is visible on (for example: http://localhost:3001/#/admin/dategrid , the default value is set in the input and applied in the filter. \r\n\r\nHowever, if I switch to another page in my menu and switch back to this page, the default filter is not set in the input nor in the filters sent to my API. In my custom restClient the params.filters are not filled. There are no errors in the console and if I press F5 the filter is set again.\r\n\r\nMaybe needed info for reproduction info: the grid is added to my <Admin.. component as a resource ad passed to the 'list' property of a resources.\r\n\r\nPs. an additional bug I found with the DateInput is that setting a defaultValue like this: new Date() works, however, set a custom date like this: new Date(2018,1,1,0,0,0) doesn't work. Don't know why, but the filter does not get applied. I have worked around that by manually checking inputs fields with default values in my restClient and manually adding them to the querystring, but it doesn't work out of the box. This issue maybe better belongs in a seperate issue however since it seems not really related.\r\n\r\nThanks!\r\n\r\nPs. I use admin-on-rest 1.4.0 according to my package.json"},"comment":{"url":"https://api.github.com/repos/marmelab/admin-on-rest/issues/comments/380774164","html_url":"https://github.com/marmelab/admin-on-rest/issues/1740#issuecomment-380774164","issue_url":"https://api.github.com/repos/marmelab/admin-on-rest/issues/1740","id":380774164,"user":{"login":"macrel","id":11870755,"avatar_url":"https://avatars3.githubusercontent.com/u/11870755?v=4","gravatar_id":"","url":"https://api.github.com/users/macrel","html_url":"https://github.com/macrel","followers_url":"https://api.github.com/users/macrel/followers","following_url":"https://api.github.com/users/macrel/following{/other_user}","gists_url":"https://api.github.com/users/macrel/gists{/gist_id}","starred_url":"https://api.github.com/users/macrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macrel/subscriptions","organizations_url":"https://api.github.com/users/macrel/orgs","repos_url":"https://api.github.com/users/macrel/repos","events_url":"https://api.github.com/users/macrel/events{/privacy}","received_events_url":"https://api.github.com/users/macrel/received_events","type":"User","site_admin":false},"created_at":"2018-04-12T11:33:41Z","updated_at":"2018-04-12T11:33:41Z","author_association":"NONE","body":"Hi,\r\n\r\nI have created a sandbox. I use admin-on-rest 1.4.0.\r\n\r\nIn the codesandbox you can see the issue of the emptied search inputs, however, the other issue I described does not occur in this sandbox. So forget about that.\r\n\r\nHere's the sandbox: https://codesandbox.io/s/1oqyzknr03\r\n\r\n- Once loaded you will see on the posts list the default search values\r\n- Now click the comments menu\r\n- Click back to posts (maybe repeat a few time)\r\n- Search inputs default values are now empty\r\n\r\nHope this helps! Looking forward to your feedback. Thanks!"}}
{"actor":{"display_login":"macrel"}}