{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/1160","repository_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl","labels_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/1160/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/1160/comments","events_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/1160/events","html_url":"https://github.com/mapbox/react-native-mapbox-gl/issues/1160","id":312026595,"number":1160,"title":"Resetting filters (at runtime) back to null does not have any affect","user":{"login":"stdavis","id":1326248,"avatar_url":"https://avatars3.githubusercontent.com/u/1326248?v=4","gravatar_id":"","url":"https://api.github.com/users/stdavis","html_url":"https://github.com/stdavis","followers_url":"https://api.github.com/users/stdavis/followers","following_url":"https://api.github.com/users/stdavis/following{/other_user}","gists_url":"https://api.github.com/users/stdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/stdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stdavis/subscriptions","organizations_url":"https://api.github.com/users/stdavis/orgs","repos_url":"https://api.github.com/users/stdavis/repos","events_url":"https://api.github.com/users/stdavis/events{/privacy}","received_events_url":"https://api.github.com/users/stdavis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-06T15:49:07Z","updated_at":"2018-04-06T17:33:22Z","closed_at":null,"author_association":"NONE","body":"I have an app that allows the user to interactively filter the operational data. Wiring up the filter state to `CircleLayer.filter` works great until I try to reset the filter back to `null`. When I try to do this, the layer does not update and continues to be filtered by the previous values.\r\n\r\nTo reproduce:\r\n- Display a CircleLayer with the initial filter set to `null`.\r\n- Add a filter (e.g. `[\"any\",[\"==\",\"Type\",\"p\"]]`)\r\n- Observe that only `p` type features are displayed on the map.\r\n- Set the filter back to `null`.\r\n- Observe that only `p` type features are still displayed on the map. It should show all features.\r\n\r\nI believe that the issue is here: https://github.com/mapbox/react-native-mapbox-gl/blob/a8d68af7efd6e55869ae3ec4fe0670ec1a58cc3d/ios/RCTMGL/RCTMGLLayer.m#L82-L84\r\n\r\nIf I remove the if block then the layer behaves as expected.\r\n\r\nI also believe that this affects all layer types, not just `CircleLayer`.\r\n\r\nAndroid appears to behave the same way although I haven't tracked down the native code yet.\r\n\r\nAm I using the `filter` property incorrectly or is this a bug? If it's a bug, I'd be willing to take a crack at a PR if you can point me in the right direction.\r\n\r\nThanks for the amazing project.\r\n\r\n```\r\n\"@mapbox/react-native-mapbox-gl\": \"^6.1.0\",\r\n\"react\": \"^16.3.0\",\r\n\"react-native\": \"0.54.2\",\r\n```"},"comment":{"url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/comments/379323246","html_url":"https://github.com/mapbox/react-native-mapbox-gl/issues/1160#issuecomment-379323246","issue_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/1160","id":379323246,"user":{"login":"nitaliano","id":1761993,"avatar_url":"https://avatars1.githubusercontent.com/u/1761993?v=4","gravatar_id":"","url":"https://api.github.com/users/nitaliano","html_url":"https://github.com/nitaliano","followers_url":"https://api.github.com/users/nitaliano/followers","following_url":"https://api.github.com/users/nitaliano/following{/other_user}","gists_url":"https://api.github.com/users/nitaliano/gists{/gist_id}","starred_url":"https://api.github.com/users/nitaliano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nitaliano/subscriptions","organizations_url":"https://api.github.com/users/nitaliano/orgs","repos_url":"https://api.github.com/users/nitaliano/repos","events_url":"https://api.github.com/users/nitaliano/events{/privacy}","received_events_url":"https://api.github.com/users/nitaliano/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T17:33:22Z","updated_at":"2018-04-06T17:33:22Z","author_association":"CONTRIBUTOR","body":"@stdavis yes great point, all of the layers are doing a null check here and we should absolutely remove this check.\r\n\r\nOn Android it's little more verbose\r\n\r\nThere is a base layer class\r\n[RCTLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTLayer.java#L237) this class has some base methods `updateFilter`, `buildFilter`, and `setFilter`.\r\n\r\nEvery layer class overrides the `updateFilter` method to call into `setFilter` you can see this in [RCTMGLFillLayer](https://github.com/mapbox/react-native-mapbox-gl/blob/master/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.java#L25)\r\n\r\nI think we need to remove this null check https://github.com/mapbox/react-native-mapbox-gl/blob/master/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTLayer.java#L164\r\n\r\nIf you want to send a PR to fix this feel free too, would be happy to review it. Even if it's only the iOS portion I can hop on the PR with you, also thanks for reporting!"}}
{"actor":{"display_login":"nitaliano"}}