Skip to content
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

Floating label cut off #1532

Closed
Gerharddc opened this issue Jan 21, 2018 · 20 comments
Closed

Floating label cut off #1532

Gerharddc opened this issue Jan 21, 2018 · 20 comments

Comments

@Gerharddc
Copy link

Gerharddc commented Jan 21, 2018

react-native, react and native-base version

  • React-Native 0.52.0

  • React: 16.2.0

  • Native-Base: 2.3.7

Expected behaviour

When using an input with a floating label, the entire label should be visible when floating.

Actual behaviour

Once the label starts floating, the top half of the label is cut off.

Steps to reproduce (code snippet or screenshot)

Something as simple as the following basic case causes it:

<Form>
  <Item floatingLabel>
    <Label>Test</Label>
    <Input />
  </Item>
  <Item floatingLabel>
    <Label>Test</Label>
    <Input />
  </Item>
  ...
</Form>

Screenshot of emulator/device

screenshot_1516514113

Is the bug present in both ios and android or in any one of them?

I am not able to test it on iOS at the moment.

Any other additional info which would help us debug the issue quicker.

It used to work a while ago but I only noticed it is broken now, not sure on which version it broke.

@sarahmarciano
Copy link

+1 I have the same issue, and it happened when I've upgraded react-native to 0.52.0

@tindery
Copy link

tindery commented Jan 22, 2018

I'm having same issue, also after upgrading to 0.52

@carathorys
Copy link

Same issue here :(
Is there any way to solve it without downgrading the react-native version?

Thanks :)

@akhil-ga
Copy link
Contributor

@carathorys you can add some padding to the top for <Label/>.

Gif

floating label

@ViktorAksionov
Copy link

ViktorAksionov commented Jan 23, 2018

I found out that Label has hard coded value for top.
In my case I did something like this to fix it:

    let top = 0;
    if ( active || input.value.length > 0) {
      top = 16;
    }

where active is meta field from redux-form

<Label style={{top}}>{labelText}</Label>

@ViktorAksionov
Copy link

ViktorAksionov commented Jan 24, 2018

Looks like it's an issue with Item component.
If you replace lineHeight from 30 to 50 here then it will not cut off Label.

Can somebody check why it has wrong value?

@SupriyaKalghatgi
Copy link
Contributor

sure

@pennyandsean
Copy link

@akhil-geekyants I appreciate the tip however a fix would be better. Want a PR?

@SupriyaKalghatgi
Copy link
Contributor

@pennyandsean There is a PR for this

@SupriyaKalghatgi
Copy link
Contributor

Fixed with 2.3.8

@raajnadar
Copy link

raajnadar commented Apr 1, 2018

This is still in Native base 2.4.1
This will be very helpful instead of hard coding in each form.

Put a padding in the theme/components/Label.js file the path may be different for you

import variable from "./../variables/platform";

export default (variables = variable) => {
	const labelTheme = {
		".focused": {
			width: 0
		},
		fontSize: 17,
		paddingTop: 2 // This much is enough to fix
	};
	return labelTheme;
};

@akhil-ga
Copy link
Contributor

akhil-ga commented Apr 3, 2018

@raajnadar checked this with native-base : 2.4.1. Couldn't see this. Posting code.
Code

import React, { Component } from 'react';
import { Container, Header, Content, Form, Item, Input, Label } from 'native-base';
export default class App extends Component {
  render() {
    return (
      <Container>
        <Header />
        <Content>
          <Form>
            <Item floatingLabel>
              <Label>Username</Label>
              <Input />
            </Item>
            <Item floatingLabel last>
              <Label>Password</Label>
              <Input />
            </Item>
          </Form>
        </Content>
      </Container>
    );
  }
}

Video

cutoff.mp4.zip

@SupriyaKalghatgi
Copy link
Contributor

@raajnadar Probably you dd'nt eject theme after updating NativeBase version

@raajnadar
Copy link

@SupriyaKalghatgi will the existing changes be overwritten after ejecting??

@ViktorAksionov
Copy link

ViktorAksionov commented May 1, 2018

@raajnadar
Ejecting just doing a simple copying, it's not a merging process, so yeah, you will loose your data in case if you ejected before and modified them.

@SupriyaKalghatgi
Copy link
Contributor

@raajnadar Yes, if there is any update in native-base/src/theme, then existing changes will be overwritten on ejecting theme
This is not merge process

@NJJ2
Copy link

NJJ2 commented May 7, 2018

I also faced same issue,

Remove
lineHeight: 18
property from component style , if you have given.
it worked for me

@SupriyaKalghatgi
Copy link
Contributor

@NaveenJayaram94 You mean, modifying in ejected theme and not updating NativeBase version?

@NJJ2
Copy link

NJJ2 commented May 7, 2018

@SupriyaKalghatgi
Native base theme works fine, doesn't need modification,
remove it from custom styles you have given to Lable or Item Component, if any.

@SupriyaKalghatgi
Copy link
Contributor

@NaveenJayaram94 Yes, no need of embedding inline styles here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants