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.

Stacked Label Input value position is not fixed on focus

See original GitHub issue

When focusing a stacked label input the position of the input text moves up some pixels. See attached screenshots.

react-native, react and native-base version

  "dependencies": {
    "native-base": "2.3.10",
    "react": "^16.3.0-alpha.1",
    "react-native": "0.54.2"
  }

Expected behaviour

Text should be fixed at same position as before the focus. The original text position should be positioned aligned with the placeholder. Instead the original text position is below the placeholder with some pixels.

Actual behaviour

Unfocused input skarmavbild 2018-03-26 kl 22 40 29

When focusing the input the input text moves up some pixels skarmavbild 2018-03-26 kl 22 40 13

Steps to reproduce (code snippet or screenshot)

<Container>
    <Content style={{paddingTop: 100}}>
        <Item stackedLabel>
            <Label>{"Stacked Label"}</Label>
            <Input value={'value'} />
        </Item>
    </Content>
</Container>

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

The issue is strangely only present on ios and not android. fixedLabel has the same issue (and maybe other input label types as well)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
andidevcommented, Mar 27, 2018

@SupriyaKalghatgi It’s because you are not setting a value directly on the Input tag.

Try setting the value with a value from the state like this:

import React, { PureComponent } from 'react';
import { Button, Container, getTheme, Header, Icon, Input, Item, Text } from 'native-base';

class App extends PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            value: 'Google',
        }
    }

    render() {
        return (
            <Container>
                <Header searchBar
                        rounded>
                    <Item>
                        <Icon name="ios-search" />
                        <Input value={this.state.value} />
                    </Item>
                    <Button transparent>
                        <Text>Cancel</Text>
                    </Button>
                </Header>
            </Container>
        );
    }
}

export default App;

and then you will get the following result: skarmavbild 2018-03-27 kl 23 32 21

1reaction
ObidosDevcommented, Apr 25, 2018

This bug makes me crazy As said @idrakimuhamad, @andidev workaround by setting lineHeight to null help to overcome this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to position input label at the top if input has a value
1 Answer 1 · Set inital value of input to "" and set the input value when keyup using Javascript. · On CSS...
Read more >
lightning-input - documentation
When the input field is focused, the input value is the multiplied number. For example, entering 1k results in 1,000 on blur, and...
Read more >
Forms
Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.
Read more >
Input
By only using the traditional label[for] method, the fixed text is never read out in the context of editing the input value. With...
Read more >
Z-index and stacking contexts - web.dev
In normal flow, if you set a specific value for z-index and it isn't working, you need to set the element's position value...
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