Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

PhoneInput: controllable country + detect country from pasted numbers

Abierto
#31 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
react, typescript
Área
frontend

Línea de trabajo

Start with the PhoneInput component's selectedCountry state, initialised from defaultCountry via getCountryByCode and COUNTRIES, and read ARCHITECTURE.md for the controlled/uncontrolled pattern and the useControllableState helper. Add country and onCountryChange props, then handle a leading + in the input by matching the longest dial code and stripping the prefix. Done when the acceptance tests pass: a controlled country follows the parent, pasting +44 selects GB, and +1 keeps CA when CA is selected, and the props table in the docs is updated.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement priority: medium

PhoneInput: controllable country + detect country from pasted numbers

Today the selected country is internal state seeded once from defaultCountry:

const [selectedCountry, setSelectedCountry] = React.useState(() => getCountryByCode(defaultCountry) ?? COUNTRIES[0]);

This breaks the library's controlled/uncontrolled convention (see ARCHITECTURE.md) — a parent can't change or reset the country, and changing defaultCountry after mount does nothing.

Proposal
  • Add country / onCountryChange and route both through useControllableState; keep defaultCountry for uncontrolled use.
  • When the user types or pastes a number starting with + (e.g. +44 20 7946 0958), match the longest dial code, switch the country and strip the prefix from the input value.
  • Shared dial codes (+1 US/CA, +7 RU/KZ): keep the currently selected country if it matches, else pick the first.
Acceptance
  • Tests: controlled country follows parent; paste +44… selects GB; +1 keeps CA if CA selected
  • Docs updated with props table
Lenguaje dominante
TypeScript
Estrellas
39
Forks
16
Merge medio
2 d 12 h
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de babelize/babelize-elements

Todos los issues de babelize/babelize-elements

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.