Skip to content

[FormField] Fields hidden when using non-stock theme #8960

Closed

Description

@rcanacci

Bug, feature request, or proposal:

Bug

What is the expected behavior?

User should be able to see the form fields (mat-form-field) displayed on the page.

What is the current behavior?

When using one of the stock angular material themes, such as '.../prebuilt-themes/deeppurple-amber.css', the fields display without issue. However, using a custom theme, the mat-form-fields are hidden by default. They are rendered on the page, but are invisible until clicked upon. When clicked, the animation occurs and moves the label up to the top (stock behavior), and the field clicked becomes visible. Also, tabbing through the fields, once one field has focus, reveals the fields one by one.

What are the steps to reproduce?

Best way to get familiar with the issue is to look here:
#3196

It's the same issue, previously closed, but I was not missing the DOCTYPE in my index.html, nor am I missing the BrowserAnimationsModule.

What is the use-case or motivation for changing an existing behavior?

No idea. Need your help to resolve that. :-)

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Browsers

Chrome 62+
Edge 40.15+
Firefox 56.0 (32-bit)

Angular

@angular/core 5.0.5
@angular/material 5.0.0

OS

Windows 10

TypeScript

2.4.2

Is there anything else we should know?

See the description below.

If I use one of the stock angular material themes such as:
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
... my inputs appear as follows...

image

... as soon as I try to implement a custom theme, here is what happens:

image

... as you can see, its basically the same the others who are experiencing the same issue... the matInputs are there but invisible.

Clicking into them does begin the animation and properly display them (one at a time).

image

Activity

  1. crisbeto commented on Dec 12, 2017

    @crisbeto
    Member

    Can you post what your theme looks like?

  2. rcanacci commented on Dec 12, 2017

    @rcanacci
    Author
  3. changed the title [-]<mat-form-field>s hidden when using non-stock angular material theme[/-] [+][FormField] Fields hidden when using non-stock theme[/+] on Dec 12, 2017
  4. rcanacci commented on Dec 15, 2017

    @rcanacci
    Author

    @mmalerba - hey there... just wanted to say thank you for looking into this issue.

    I was curious if there had been any progress during the course of the last few days... or even just an idea as to the nature of the issue... how likely you feel it would be to being solved, etc. No pressure regarding time, just curious for a status update / thoughts on how this issue looks.

    Thanks in advance for all of the assistance on this issue.

  5. mmalerba commented on Dec 15, 2017

    @mmalerba
    Contributor

    It looks like you're using a dark theme, but in your screenshot the background is white. Dark themes expect to be used on a dark background.

    You could try adding this to your CSS:

    .alt-button-theme {
      @include mat-button-theme($alt-button-theme);
    
      // Add dark color background to root alternate theme element
      $background: map-get($dark-theme, background);
      background: map-get($background, card);
    }
  6. rcanacci commented on Dec 18, 2017

    @rcanacci
    Author

    @mmalerba - Thank you for responding.

    Adding the code change that you suggested prevents the code from compiling.

    Are you inferring here that $dark-theme should be an altogether separate theme that should be defined and then applied here?

    $background: map-get($dark-theme, background);

    At this point, $dark-theme is not defined.

    Note:
    @mmalerba - just so we're clear on what my ultimate goal is here, since I didn't clearly state it above. My only goal is to have a simple, standard color-scheme applied to my form element label and control text. Black, dark-gray, etc... red-coloring for errors... just what might be considered a simple/standard color scheme for the web. If there is a built-in theme that achieves this (that is visible on a white background), then let me know - happy to just use that and move away from trying to define a custom theme.

    Thanks.

  7. mmalerba commented on Dec 18, 2017

    @mmalerba
    Contributor

    Oh sorry I didn't notice your alternate theme only applied to the button anyways. But your custom theme is also defined as a dark theme

    $custom-theme: mat-dark-theme($custom-primary, $custom-accent);
    @include angular-material-theme($custom-theme);

    If you want the colors to show up right for a dark theme you need to make the background element a dark color. If you actually wanted a light theme use mat-light-theme instead.

  8. dannythebestguy commented on Dec 22, 2017

    @dannythebestguy

    So does this mean that in a dark theme, the forms cannot be displayed on a white background ?

    Normally Forms are on white background irrespective of dark/light theme of a website.

    In any way can we change the component's light/dark feature and keep the main theme as it is ?

  9. mmalerba commented on Dec 22, 2017

    @mmalerba
    Contributor

    You can use a dark theme for your app and a light theme for your forms if you like. Explanation of how to use multiple themes is here: https://material.angular.io/guide/theming#multiple-themes

    Closing this issue since it's not a bug.

  10. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions