Title: ScrollView with GridLayout does not correctly update on IOS · Issue #1593 · NativeScript/nativescript-angular · GitHub
Open Graph Title: ScrollView with GridLayout does not correctly update on IOS · Issue #1593 · NativeScript/nativescript-angular
X Title: ScrollView with GridLayout does not correctly update on IOS · Issue #1593 · NativeScript/nativescript-angular
Description: Environment CLI: 5.0.0 Cross-platform modules: 5.0.1 Android Runtime: 5.0.0 iOS Runtime: 5.0.0 Plugin(s): "nativescript-iqkeyboardmanager": latest "nativescript-loading-indicator-new": "^2.1.0", "nativescript-loading-screen": "^1.0.6", "...
Open Graph Description: Environment CLI: 5.0.0 Cross-platform modules: 5.0.1 Android Runtime: 5.0.0 iOS Runtime: 5.0.0 Plugin(s): "nativescript-iqkeyboardmanager": latest "nativescript-loading-indicator-new": "^2.1.0", "n...
X Description: Environment CLI: 5.0.0 Cross-platform modules: 5.0.1 Android Runtime: 5.0.0 iOS Runtime: 5.0.0 Plugin(s): "nativescript-iqkeyboardmanager": latest "nativescript-loading-indicator-new...
Opengraph URL: https://github.com/NativeScript/nativescript-angular/issues/1593
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ScrollView with GridLayout does not correctly update on IOS","articleBody":"**Environment**\r\n - CLI: 5.0.0\r\n - Cross-platform modules: 5.0.1\r\n - Android Runtime: 5.0.0\r\n - iOS Runtime: 5.0.0\r\n - Plugin(s):\r\n\"nativescript-iqkeyboardmanager\": latest\r\n\"nativescript-loading-indicator-new\": \"^2.1.0\",\r\n\"nativescript-loading-screen\": \"^1.0.6\",\r\n\"nativescript-material-icons\": \"^1.0.3\",\r\n\"nativescript-ngx-fonticon\": \"^4.1.0\",\r\n\"nativescript-plugin-firebase\": \"^7.2.0\",\r\n\"nativescript-sqlite\": \"^2.2.3\",\r\n\"nativescript-sse\": \"^4.0.2\"\r\n\r\n - NativeScript-Angular: 6.2.0\r\n - Angular: 6.1.0\r\n \r\n**Describe the bug**\r\nI have a layout that consists of a ScrollView with embedded StackLayout and GridLayout. The GridLayout is repeated with ngFor:\r\n```\r\n\u003cScrollView #messagesView id=\"messagesView\"\u003e\r\n \u003cStackLayout id=\"stackLayout\" style=\"padding-bottom: 10;\" id=\"stackLayout\"\u003e\r\n \u003cGridLayout *ngFor=\"let message of messages\" columns=\"auto, * , auto\"\u003e\r\n \u003cLabel *ngIf=\"sentByMe(message)\" col=\"2\" [text]=\"message[2]\" textAlignment=\"right\" style=\"margin-top: 10; margin-right: 10; padding: 5; background-color: #11a1ce; color: white;\"\u003e\u003c/Label\u003e\r\n \u003cLabel *ngIf=\"!sentByMe(message)\" col=\"0\" [text]=\"message[2]\" textAlignment=\"left\" style=\"margin-top: 10; margin-left: 10; padding: 5; background-color: white;\"\u003e\u003c/Label\u003e\r\n \u003c/GridLayout\u003e\r\n \u003c/StackLayout\u003e\r\n\u003c/ScrollView\u003e\r\n```\r\nThis works fine on first rendering, but as soon as I add new items to the array (messages), I notice an UI bug: An empty element is added at the bottom (I can see it due to the space that it covers) and the text of the message appears at the very beginning of the scrollview. I didn't find any other option than scrolling to the top of the scrollView, add the item and then scroll back to the bottom. Only in this case, the new item is correctly placed at the end of the scrollview. But this is annoying as you can see the \"jump\" (due to the fact that I even need a small delay of around 100 ms with setTimeout):\r\n\r\n```\r\nif (isIOS) {\r\n if (parseInt(device.osVersion, 10) \u003e 10) {\r\n this.messagesView.nativeElement.scrollToVerticalOffset(0, false);\r\n } else { \r\nthis.messagesView.nativeElement.scrollToVerticalOffset(this.messagesView.nativeElement.scrollableHeight - 1, false);\r\n }\r\n}\r\n\r\nconst messageText = this.messageToSend;\r\nconst newMessage = [ 0, 0, this.messageToSend, Date.now().toString(), this.id, this.loginService.userid, 1 ];\r\nconst newMessagesArrayLength = this.messages.push(newMessage);\r\n\r\nif (isIOS) {\r\n setTimeout(() =\u003e {\r\n this.ngZone.run(() =\u003e { \r\nthis.messagesView.nativeElement.scrollToVerticalOffset(this.messagesView.nativeElement.scrollableHeight, false);\r\n });\r\n }, 100);\r\n}\r\n```\r\n\r\nIs there any chance to force re-rendering of ScrollView without scrolling to top/bottom?\r\n\r\n**To Reproduce**\r\nSee above.\r\n\r\n**Expected behavior**\r\nThe item should be added and ScrollView should be updates correctly with the new item at the end.\r\n\r\n**Sample project**\r\n\r\n**Additional context**\r\nOnly happens on iOS. I have to use this construction of layouts as using a ListView causes other issues with the keyboard hiding content on iOS.\r\n","author":{"url":"https://github.com/cremfert","@type":"Person","name":"cremfert"},"datePublished":"2018-11-07T11:27:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1593/nativescript-angular/issues/1593"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:39d1d464-b288-d7a4-13f9-1cb4eb0ae14b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E6AA:340321:437DB2D:578A332:6974F22E |
| html-safe-nonce | 5a6ff987c7742a9a0f739cbd4eeb8415bf6b9022f1aedc0b9ea83675e86c7b3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkFBOjM0MDMyMTo0MzdEQjJEOjU3OEEzMzI6Njk3NEYyMkUiLCJ2aXNpdG9yX2lkIjoiNDQ4MjMwOTU4NzkyMjY0NTU1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1cd27277df1944f74fb656c710bacae929c4e02361dc6271f1ab4b59da77ce76 |
| hovercard-subject-tag | issue:378248421 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/nativescript-angular/1593/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ab408d5837c5797c3ff7b5a424885046c1ee3bcbc9e442b309e31ebf44ea959/NativeScript/nativescript-angular/issues/1593 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ab408d5837c5797c3ff7b5a424885046c1ee3bcbc9e442b309e31ebf44ea959/NativeScript/nativescript-angular/issues/1593 |
| og:image:alt | Environment CLI: 5.0.0 Cross-platform modules: 5.0.1 Android Runtime: 5.0.0 iOS Runtime: 5.0.0 Plugin(s): "nativescript-iqkeyboardmanager": latest "nativescript-loading-indicator-new": "^2.1.0", "n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cremfert |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/nativescript-angular git https://github.com/NativeScript/nativescript-angular.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 35951404 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 35951404 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width