Skip to content

RadDatForm styling is not working #260

Open

Description

@jmdavid
  • CLI: 6.5.0
  • Android Runtime: 10
  • Plugin(s): "nativescript-ui-dataform": "^6.0.0",

In my project, I use themes:

@import "~@nativescript/theme/core";

In one of my components, I use RadDataForm.
For picker input, the arrow is hidden.
I cannot apply TKPropertyEditorStyle, it is ignored completely.

<TKEntityProperty tkDataFormProperty name="name" displayName="Name" index="0>
     <TKPropertyEditor tkEntityPropertyEditor type="Text">
        <TKPropertyEditorStyle tkPropertyEditorStyle strokeColor="#00695c" strokeWidth="2" fillColor="#4db6ac" labelHidden="false"
                labelTextSize="18" ios:labelFontName="Times New Roman" android:labelFontName="sans-serif-light" labelFontStyle="Italic"
                labelPosition="Top" labelTextColor="#00695c">
        </TKPropertyEditorStyle>
    </TKPropertyEditor>
</TKEntityProperty>

nsbug

If I import compat (@import "~@nativescript/theme/core.compat";), it works.

So there is an incompatibility with new themes and Rad component.
How can I fix it without using old compat (that makes my app ugly)?

Thanks.

Activity

  1. jmdavid commented on Apr 10, 2020

    @jmdavid
    Author

    Here are the steps to reproduce.

    > tns create bugng --template tns-template-drawer-navigation-ng
        found 6 vulnerabilities (5 moderate, 1 high)
    > npm audit fix
        3 vulnerabilities required manual review and could not be updated
        1 package update for 1 vulnerability involved breaking changes
    > npm audit fix --force
    > tns plugin add nativescript-ui-dataform
    

    Then, in app.module.ts, added:

    import { NativeScriptFormsModule } from "nativescript-angular/forms";
      ...
      imports: [
        ...
        NativeScriptFormsModule
      ]
    

    Then, in home.module.ts, added:

    import { NativeScriptUIDataFormModule } from "nativescript-ui-dataform/angular";
      ...
      imports: [
        ...
        NativeScriptUIDataFormModule
      ]
    

    home.component.ts :

    import { Component, OnInit, ViewChild } from "@angular/core";
    import { RadSideDrawer } from "nativescript-ui-sidedrawer";
    import * as app from "tns-core-modules/application";
    import { RadDataFormComponent } from "nativescript-ui-dataform/angular/dataform-directives";
    
    @Component({
        selector: "Home",
        templateUrl: "./home.component.html"
    })
    export class HomeComponent implements OnInit {
    
        @ViewChild('myCommitDataForm', { static: false }) myCommitDataFormComp: RadDataFormComponent;
        private _person: Person;
    
        constructor() {
            // Use the component constructor to inject providers.
        }
    
        ngOnInit(): void {
            this._person = new Person("John", 23, "[email protected]", -1);
        }
    
        onDrawerButtonTap(): void {
            const sideDrawer = <RadSideDrawer>app.getRootView();
            sideDrawer.showDrawer();
        }
    
        public onPropertyCommitted(args) {
            console.log(args.propertyName);
            if (this.myCommitDataFormComp.dataForm.editedObject) {
                console.log(this.myCommitDataFormComp.dataForm.editedObject);
            }
        }
    
        get person(): Person {
            return this._person;
        }
    }
    
    class Person {
        constructor(public name: string, public age: number, public email: string, public city?: number) { }
    }
    

    home.component.html :

    <ActionBar>
        <NavigationButton ios:visibility="collapsed" icon="res://menu" (tap)="onDrawerButtonTap()"></NavigationButton>
        <ActionItem icon="res://menu" android:visibility="collapsed" (tap)="onDrawerButtonTap()"
            ios.position="left">
        </ActionItem>
        <Label text="Home"></Label>
    </ActionBar>
    
    <GridLayout class="nt-form" rows="132,auto,auto,*">
        <Image height="128" src="res://logo"></Image>
        <Label row="1" class="page__content-placeholder" text="<!-- Page content goes here -->"></Label>
        <RadDataForm row="2" #myCommitDataForm [source]="person" tkExampleTitle tkToggleNavButton commitMode="Immediate" (propertyCommitted)="onPropertyCommitted($event)">
            <!-- >> angular-dataform-adjustment-html -->
            <TKEntityProperty tkDataFormProperty name="name" displayName="Name" index="0">
                <TKPropertyEditor tkEntityPropertyEditor type="Text">
                    <TKPropertyEditorStyle tkPropertyEditorStyle strokeColor="#00695c" strokeWidth="2" fillColor="#4db6ac" labelHidden="false"
                    labelTextSize="18" ios:labelFontName="Times New Roman" android:labelFontName="sans-serif-light" labelFontStyle="Italic"
                    labelPosition="Top" labelTextColor="#00695c"></TKPropertyEditorStyle>
                </TKPropertyEditor>
                <TKNonEmptyValidator tkEntityPropertyValidators errorMessage="Username can't be empty."></TKNonEmptyValidator>
            </TKEntityProperty>
            <TKEntityProperty tkDataFormProperty name="age" displayName="Age" index="1">
                <TKPropertyEditor tkEntityPropertyEditor type="Number"></TKPropertyEditor>
            </TKEntityProperty>
            <TKEntityProperty tkDataFormProperty name="email" displayName="E-Mail" index="2">
                <TKPropertyEditor tkEntityPropertyEditor type="Email"></TKPropertyEditor>
            </TKEntityProperty>
            <TKEntityProperty tkDataFormProperty name="city" displayName="City" index="3" valuesProvider="Montreal, Quebec, Toronto" hintText="city">
                <TKPropertyEditor tkEntityPropertyEditor type="Picker"></TKPropertyEditor>
                <TKNonEmptyValidator tkEntityPropertyValidators errorMessage="City can't be empty."></TKNonEmptyValidator>
            </TKEntityProperty>
        </RadDataForm>
    </GridLayout>
    
  2. self-assigned this
    on Apr 12, 2020
  3. jmdavid commented on Apr 22, 2020

    @jmdavid
    Author

    I haven't tested on iOS so far, I did and it works.
    So the bug is only in Android.

  4. bundyo commented on May 27, 2020

    @bundyo
    Contributor

    Looks like just setting background-color or border to the text fields will reset all borders and the dropdown caret. Unfortunately removing those styles will break the dark mode styling, as the border and the dropdown caret remain black. So this looks more like a styling bug in RadDataForm.

    As for the text field text styling - this is a bug/design decision in {N} - CSS styling has more priority than the properties of the control, so it won't be applied. You can override it with CSS with higher specificity. Something along those lines:

    .ns-root PropertyEditor[type='Text'] DataFormEditorLabel {
        font-size: 18;
        font-style: italic;
        color: #00695c;
        position: top;
    }
    
    .ns-root PropertyEditor[type='Text'] DataFormEditorCore {
        border-color: #00695c; 
        border-width: 2;
        background-color: #4db6ac;
    }
  5. bundyo commented on May 27, 2020

    @bundyo
    Contributor

    For just Android, like this:

    .ns-android PropertyEditor[type='Text'] DataFormEditorLabel {
        font-size: 18;
        font-style: italic;
        color: #00695c;
        position: top;
    }
  6. houssammehdi commented on Jun 4, 2020

    @houssammehdi

    All my RadDataForms started to look like this suddenly.

    Is this the same problem?

    https://github.com/NativeScript/NativeScript/issues/8607#issue-629523503

    Is there a way to remove those styles being applied?

  7. bundyo commented on Jun 4, 2020

    @bundyo
    Contributor

    Yes, looks like it.

  8. houssammehdi commented on Jun 6, 2020

    @houssammehdi

    @bundyo is there a way to disable all this styling? I want my fields to have the default look on iOS. I've been looking everywhere with no hope, if I create a new project and add RadDataForm it doesn't look like the image shown at all. (My github issue ref)

  9. bundyo commented on Jul 3, 2020

    @bundyo
    Contributor

    You can try if compat mode helps, but I guess not completely.

    Maybe I can separate the {N}-UI components styling in a separate file that can be optionally not loaded. What do you think?

  10. gustavotrott commented on Apr 3, 2023

    @gustavotrott

    For me it is caused by the @import '@nativescript/theme/css/core.css';.

    specifically this style:

    PickerField, DatePickerField, TimePickerField, DateTimePickerFields, DataFormEditorCore, RadAutoCompleteTextView {
      background-repeat: no-repeat;
      background-position: right center
    }
    

    But I'm not able to fix it... if I set any background* style to DataFormEditorCore, it stops showing the caret.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions