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

Aperta Adatta ai principianti
#5,187 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react-native, typescript
Ambito
frontend

Direzione di ricerca

Inizia da src/components/TextInput/hooks.ts e TextInput.tsx:401, dove animatedContainerStyle viene applicato al wrapper nativo dell’input. Verifica come l’opacità dipende dalla presenza di un’etichetta, quindi aggiungi o adatta un test per un TextInput vuoto, non focalizzato e senza etichetta. Il lavoro è completato quando il suo segnaposto è visibile e l’input con etichetta mantiene il comportamento dell’etichetta flottante.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
14.5k
Fork
2.3k
Merge medio
2g 12h
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di callstack/react-native-paper

Tutte le issue di callstack/react-native-paper

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.