Skip to content

Floating label on ion-datetime always floats if it's in a formGroup or has ngModel #11547

Closed

Description

@imgx64

Ionic version: (check one with "x")
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report

Current behavior:
A floating label on <ion-datetime> always floats above the input, even if no date is selected. This happens if the ion-datetime has ngModel or is in a formGroup. If it's neither, then it only floats when a date is selected (but then it becomes useless, as you can't actually get the value).

screenshot

Expected behavior:
The floating label should only float when a date is selected.

Steps to reproduce:
See this plunker

Related code:
Other information:
I think the issue is in the hasValue() method in base-input.ts. It returns true if the datetime has the "empty" date (which is just {}). Either ion-datetime should have null or undefined value until a date is selected, or it could override hasValue() and return false if the value is {}.

Ionic info:

> ionic info

Your system information:

 ordova CLI: 7.0.0
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.6
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.3
Xcode version: Not installed```

Activity

  1. gandrade74 commented on May 8, 2017

    @gandrade74

    Same problem here.

  2. added a commit that references this issue on May 8, 2017
    5a895bb
  3. ionitron-bot commented on Sep 3, 2018

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions