question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Datepicker with Item floatingLabel not working

See original GitHub issue

I have gone through these following points

Issue Description

Software versions:

node v8.11.1, npm 5.6.0, react-native 0.57.1, react 16.5.0 and native-base 2.8.0

What is happening?

Expected to open Datepicker when click an Item floating label. But, when the Item has “floatingLabel” flag, Datepicker do not open anyway. I searched a lot here, in the docs and in StackOverflow, but seems that anyone experienced this before. When Item has no flag, it works pretty normal. I tried to call the showDatePicker() programatically, but the Datepicker seems do not accept “ref” or “getRef” props.

I tried to put an Input component too, to handle the Datepicker inside it, but no success. Is it a bug or I making something wrong?

What I really want is a form Input that is a Datepicker.

The code that I using:

import React, { Component } from 'react';
import { View } from 'react-native';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Creators as SignupActions } from 'store/ducks/signup';

import { Form, Item, Button, DatePicker, Label, Text, Icon } from 'native-base';

import PropTypes from 'prop-types';
import moment from 'moment';
import { Wrapper } from 'components';

import styles from './styles';

class Signup extends Component {
  static navigationOptions = {
    title: 'Cadastrar',
  };
  static propTypes = {
    signupRequest: PropTypes.func.isRequired,
  };
  state = {
    birthDate: new Date(),
  };

  handleSignup = () => {
    console.log(this.state);
  };

  handleBirthDate = (date) => {
    this.setState({ birthDate: moment(date).toDate() });
  };

  render() {
    return (
      <Wrapper>
        <Form style={styles.formContainer}>
          <Item floatingLabel>
            <Label>
              <Text>Data de aniversário</Text>
            </Label>
            <DatePicker
              defaultDate={new Date()}
              maximumDate={new Date()}
              locale="pt"
              timeZoneOffsetInMinutes={undefined}
              modalTransparent={false}
              animationType="fade"
              androidMode="default"
              placeHolderText="Data"
              placeHolderTextStyle={{ color: '#d3d3d3' }}
              onDateChange={this.handleBirthDate}
            />
            <Icon name="ios-calendar" style={{ color: '#fff' }} />
          </Item>
          <Button onPress={this.handleSignup}>
            <Text>Cadastrar</Text>
          </Button>
        </Form>
      </Wrapper>
    );
  }
}

const mapDispatchToProps = dispatch => bindActionCreators(SignupActions, dispatch);

export default connect(null, mapDispatchToProps)(Signup);
  • The Wrapper component is a NativeBase Container with black backgroundColor and padding of 5px.

I tested only in Android, because I can’t test in iOS with my computer, and don’t have an Iphone. But I believe that it occurs in iOS too.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
italomlpcommented, Mar 11, 2019

Any updates here? I can help, if needed.

3reactions
HugoLiconVcommented, Sep 18, 2019

I’m trying to use DatePicker inside Item too. Tested all label types. Here’s what I found out:

  • floatingLabel: DatePicker doesn’t show
  • stackedLabel: DatePicker shows aligned center.
  • fixedLabel: DatePicker shows aligned right.
  • inlineLabel: DatePicker aligned left but not one with each other

Seems to me that, apart from floatingLabel, everyghing else works. Would be nice if we could specify the input alignment for DatePicker.

Thanks! inlineLabel worked perfectly for me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with datepicker template and my custom javascript ...
I am trying to include a nice looking date input field on my webpage. I have already done the styling of my input...
Read more >
Float Label Is Not Working When Manually Enter Date
Hi, I My Project I am working on blazor project.In this project we are using material css. so when I select date from...
Read more >
Add floating labels on the DatePicker and DateTimePicker
Hello, Abhilash,. Thank you for noticing this. This occurs as we are passing directly a function in the render, but React does not...
Read more >
Input label does not move up when value or placeholder is sp
In Your case I suggest to replace label by the placeholder attribute. Dynamic input changes very often causes unexpected issues. Best regards. Add...
Read more >
Floating Labels - React-Bootstrap
Control> element in <FloatingLabel> to enable floating labels with ... To set a custom height on your <textarea> , do not use the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found