TextInput without a label is invisible while it is empty and unfocused

Open Beginner friendly
#5,187 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react-native, typescript
Domain
frontend

Research direction

Start with src/components/TextInput/hooks.ts and TextInput.tsx:401, where animatedContainerStyle is applied to the native input wrapper. Check how opacity depends on whether a label is present, then add or adapt a test for an empty, unfocused TextInput without a label. Done when its placeholder is visible while the labeled input keeps its floating-label behavior.

Written by the indexing model from the issue text.

Description

bug
Current behaviour

A TextInput with no label is invisible while it is empty and unfocused: its input, its placeholder and any prefix or suffix have opacity 0, so only the outline shows until the field is focused. The wrapper around the native input takes the label float opacity (animatedContainerStyle in src/components/TextInput/hooks.ts, applied at TextInput.tsx:401) whether or not there is a label, and that value is 0 while the field is empty and unfocused. In 5.x the placeholder was visible.

Expected behaviour

A TextInput without a label shows its input and placeholder at full opacity at all times. Only a TextInput with a label hides the input while the label rests in its place.

How to reproduce?
const [query, setQuery] = React.useState('');

<TextInput
  variant="outlined"
  placeholder="Search for plugins..."
  value={query}
  onChangeText={setQuery}
/>
  1. Render it: only the outline shows, with no placeholder.
  2. In a test, expect(screen.getByPlaceholderText('Search for plugins...')).toBeVisible() fails with "Received element is not visible".
What have you tried so far?

Applying animatedContainerStyle only when label is set keeps the floating label behaviour and shows the placeholder.

Your Environment
software version
react-native 0.88.1
react-native-paper 6.0.0-alpha.1 and main at c8d8bab
Dominant language
TypeScript
Stars
14.5k
Forks
2.3k
Avg merge
2d 12h
Merged PRs (30d)
22

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from callstack/react-native-paper

All issues in callstack/react-native-paper

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.