-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android only: Broken GridLayout with angular 17.3.0. With 17.2.1 thing were working #129
Comments
Hello! Can you please enable the NativeScript Angular logs (set Trace.enable() in your polyfills.ts, and enable the You should be seeing this log on the screen:
I suspect this issue comes from the angular side, not our side, so most likely that log will be setting the string value itself instead of evaluating the expression. The NativeScript angular integration doesn't evaluate any expressions, we just apply what angular provides to us via the Renderer2 API |
Hello @edusperoni , not sure how I have to do it. could you please explain what I have to set in polyfills.ts. import { Trace } from '@nativescript/core'; However, there seems to be no category NativeScriptDebug.rendererTraceCategory |
@edusperoni, I tried to set
and I also tried to set it as string Trace.addCategories('NativeScriptDebug.rendererTraceCategory'). The later does not work and the first one does not result in any output of NativeScriptDebug.rendererLog. I finally also tried to set in src/polyfill.ts, but I do not get any NativeScriptRenderer.setAttribute output either. Please provide a more detailed description how I can enable it. |
The NativeScriptDebug is exported as |
I now did try both variants in app.module.ts, but I do not see any output import { Trace } from '@nativescript/core'; import { ɵNativeScriptAngularDebug } from '@nativescript/angular'; and Trace.addCategories('ns-renderer'); |
ok, got it. Had to go into polyfills.ts It looks like the expression is evaluated, see attached file line 1404 and 1405
This looks correct? It looks awkward to me ":android:" Update: I just compared it against the old NS Angular version 17.2.1 there it looks different
Seems like the android prefix is broken? Should be removed? |
@cjohn001 is there any calls to setAttribute on the old one? Seems like the new version isn't calling Seems like angular might have changed the way it stets these kinds of properties. I'll take a look later if this is something it makes sense for us to support or not. In the meantime I highly recommend using a function/getter instead and bind that to the colums/rows, as it'll avoid multiple evaluation calls too (right now your code will process row/columns for both platforms, but only select one of them). Something like:
|
@edusperoni you mean if I am calling setAttribute? No. In regards to the android: ios: you do not want to support it anymore? In that case I would have to check my entire code for it. Use it for multiple attributes.. One more question to this regarding efficiency. I think to remember to have red that I also should not call functions from templates when possible as those are to be evaluated for each redraw. I am therefore wondering if the approach you provided is more efficient. Or should I maybe use a signal for it? Seems like those somtimes work and sometimes do not. I observed them not to refresh. However, here refresh is not required as the platform never changes |
it's not that we don't want to support it anymore, it's that angular is changing how it sets those, so we'd need to work around it. Ever since I wrote the tests for it, dynamic values didn't work properly (while static values like you tried, work, because properties don't have namespaces, while attributes do). I personally don't use that feature for dynamic values because of that, and most of the time it's better to use a getter or function instead. |
Ok, than I better change my code. Would be good to skip this feature than with a new major release. How about using a signal instead. I think you had answered before I finished updating my question :) |
And maybe a last question to the topic. I am wondering why this stuff works on ios and not on android. I thought the same angular library is used on both platforms. Do you have an idea why this could be? |
it seems like your code on iOS is static, while android has dynamic content. So most likely angular itself is using setAttribute (correctly) on iOS and setProperty on Android (which has no namespace support) |
It also affects platform-specific css (https://docs.nativescript.org/guide/styling#platform-specific-css) when used with dynamic values. |
Dependencies
Describe the bug
I am having a grid layout showing tiles see images attached, those are set up using the following code snipped
When moving from angular 17.2.1 to 17.3.0 this layout breaks because of the following line
android:columns="{{(_tinyScreen || _smallScreen) ? '*,5,*' : '*,10,*'}}" android:rows="{{(_tinyScreen || _smallScreen) ? '*,5,*,5,*' : '*,10,*,10,*' }}
_tinyScreen and _smallScreen are booleans both set to false. When I set columns and rows to a fixed value things are working as expected.
I also tried to change the property binding to the following line, but this also does not work:
[android:columns]="(_tinyScreen || _smallScreen) ? '*,5,*' : '*,10,*'" [android:rows]="(_tinyScreen || _smallScreen) ? '*,5,*,5,*' : '*,10,*,10,*' "
To Reproduce
Expected behavior
Sample project
Additional context
The text was updated successfully, but these errors were encountered: