{"action":"created","issue":{"url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/issues/735","repository_url":"https://api.github.com/repos/telerik/nativescript-ui-feedback","labels_url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/issues/735/labels{/name}","comments_url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/issues/735/comments","events_url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/issues/735/events","html_url":"https://github.com/telerik/nativescript-ui-feedback/issues/735","id":341418326,"node_id":"MDU6SXNzdWUzNDE0MTgzMjY=","number":735,"title":"AutoCompleteTextView - modify array of tokens if a token is selected / removed","user":{"login":"suparnavg","id":1419812,"node_id":"MDQ6VXNlcjE0MTk4MTI=","avatar_url":"https://avatars3.githubusercontent.com/u/1419812?v=4","gravatar_id":"","url":"https://api.github.com/users/suparnavg","html_url":"https://github.com/suparnavg","followers_url":"https://api.github.com/users/suparnavg/followers","following_url":"https://api.github.com/users/suparnavg/following{/other_user}","gists_url":"https://api.github.com/users/suparnavg/gists{/gist_id}","starred_url":"https://api.github.com/users/suparnavg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suparnavg/subscriptions","organizations_url":"https://api.github.com/users/suparnavg/orgs","repos_url":"https://api.github.com/users/suparnavg/repos","events_url":"https://api.github.com/users/suparnavg/events{/privacy}","received_events_url":"https://api.github.com/users/suparnavg/received_events","type":"User","site_admin":false},"labels":[{"id":515096060,"node_id":"MDU6TGFiZWw1MTUwOTYwNjA=","url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/labels/autocomplete","name":"autocomplete","color":"eb6420","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-16T07:43:59Z","updated_at":"2018-07-17T12:39:06Z","closed_at":"2018-07-17T12:39:06Z","author_association":"NONE","body":"<!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nIf the below information is not provided we may not be able to respond and/or assist you in time and your report maybe closed without investigation.\r\n-->\r\n\r\n> Please take a minute to read our [NativeScript Code of Conduct](https://github.com/NativeScript/codeofconduct) before proceeding with posting issues or discussing. The purpose of this guide is to make communication and cooperation within our forums a pleasure for you and the other members.\r\n\r\n## Please, provide the details below:\r\n\r\n### Did you verify this is a real problem by searching the [NativeScript Forum](https://discourse.nativescript.org/)?\r\nYes\r\n\r\n### Tell us about the problem\r\n_Please, ensure your title is less than 63 characters long and starts with a capital\r\nletter._\r\nAutoCompleteTextView should dynamically change the list of available tokens.\r\n\r\n### Which platform(s) does your issue occur on?\r\nAndroid \r\n\r\n### Please provide the following version numbers that your issue occurs with:\r\n- **Progress NativeScript UI version: 3.6.0\r\n- **CLI:** 4.1.0\r\n- **Cross-platform modules:** 4.2.0-2018-06-29-01\r\n- **Runtime(s):** '\"tns-android\"` \"version\": \"4.1.3\"\r\n\r\n### Please tell us how to recreate the issue in as much detail as possible.\r\n1. Include the `RadAutoCompleteTextView` component in your application, load with data items (normal implementation).\r\nOn selecting a token, it should get removed from the array of available tokens (so it cannot be selected again). On removing a token, it should get added back into the array of available tokens.\r\n\r\nI tried to do this with the following snippet to filter the ObservableArray<TokenModel> on the token added / removed events with the following error:\r\n\r\nSnippet:\r\n```\r\npublic onTokenAdded(args) {\r\n        // Do something with the args\r\n        // Filter the ObservableArray\r\n        this._items = this.filterTokenArray(args.token.text);\r\n}\r\n\r\nfilterTokenArray(compare): ObservableArray<TokenModel> {\r\n        return this._items().map(items => items.filter(item => item.text !== compare));\r\n}\r\n\r\n```\r\n\r\nError: Cannot invoke an expression whose type lacks a call signature. Type 'ObservableArray<TokenModel>' has no compatible call signatures\r\n\r\n\r\nOpening this as a potential feature here because this seems like a pretty common requirement.. dynamically changing the array of available tokens will make for a better UX. Maybe there can be flag in the RadAutoCompleteTextView to turn this feature on / off."},"comment":{"url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/issues/comments/405567323","html_url":"https://github.com/telerik/nativescript-ui-feedback/issues/735#issuecomment-405567323","issue_url":"https://api.github.com/repos/telerik/nativescript-ui-feedback/issues/735","id":405567323,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTU2NzMyMw==","user":{"login":"suparnavg","id":1419812,"node_id":"MDQ6VXNlcjE0MTk4MTI=","avatar_url":"https://avatars3.githubusercontent.com/u/1419812?v=4","gravatar_id":"","url":"https://api.github.com/users/suparnavg","html_url":"https://github.com/suparnavg","followers_url":"https://api.github.com/users/suparnavg/followers","following_url":"https://api.github.com/users/suparnavg/following{/other_user}","gists_url":"https://api.github.com/users/suparnavg/gists{/gist_id}","starred_url":"https://api.github.com/users/suparnavg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suparnavg/subscriptions","organizations_url":"https://api.github.com/users/suparnavg/orgs","repos_url":"https://api.github.com/users/suparnavg/repos","events_url":"https://api.github.com/users/suparnavg/events{/privacy}","received_events_url":"https://api.github.com/users/suparnavg/received_events","type":"User","site_admin":false},"created_at":"2018-07-17T12:39:06Z","updated_at":"2018-07-17T12:39:06Z","author_association":"NONE","body":"@NickIliev sorry for that mistake on my part. It is in fact a property of type ObservableArray<TokenModel> and I made the change you suggested.\r\n\r\nFor future readers, I implemented this like so:\r\n\r\n```\r\npublic onTokenAdded(args) {\r\n        // Do something\r\n        this.filterTokenArray(args.token.text);\r\n    }\r\nfilterTokenArray(compare) : void {\r\n        var array : ObservableArray<TokenModel> = new ObservableArray();\r\n        this._items.map(item => {\r\n            if (item.text !== compare) {\r\n                array.push(new TokenModel(item.text, null));\r\n            }\r\n        });\r\n        this._items = array;\r\n    }\r\n```\r\n\r\nAnd a similar map function to add the token back to _items when it is deselected. Thanks @NickIliev !\r\n\r\n\r\n"}}
{"actor":{"display_login":"suparnavg"}}