Cannot focus an input right after enabling it
Los mantenedores suelen responder en 1 día
@alicewriteswrongs ya está trabajando en esto.
Desde el 27/10/2022.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Stencil version:
@stencil/[email protected]
Current behavior:
We have a wrapper around an HTML <input> , essentially this (most of the implementation elided for brevity):
export class WrapperTextInput {
@Prop({ mutable: true }) value: string;
@Prop() readonly disabled: boolean = false;
render() {
return (
<Host role="textbox" contenteditable="true">
<div>
<input type="text" value={this.value} disabled={this.disabled}></input>
</div>
</Host>
);
}
Now let's say the WrapperTextInput is disabled, and you run the following code:
wrapperTextInput.disabled= false;
wrapperTextInput.focus();
The call to focus() does not work. The component does not receive focus.
The following is a workaround:
wrapperTextInput.disabled= false;
setTimeout(() => wrapperTextInput.focus(), 50);
This is surprising to users of our components, considering a native <input> handles this without the need for a delay. This is even more awkward in React, as users expect a change in properties to be reflected in the DOM by the time the next useEffect runs, for instance.
I assume this workaround works because it gives the component time to render in its non-disabled state so it can be focused. Does this analysis make sense?
Expected behavior:
It should be possible to focus the component right after setting the disabled property to true.
Repro steps:
Repro here: https://github.com/asik/stencil-focus-issue-repro
You'll be able to see that the native input receives focus, but not the one wrapped in a stencil component.

(Clicked the Toggle native button, focus is given to the native input)

(Clicked the Toggle Stencil button, focus is not given to the stencil component.)
Other information:
Somewhat related https://github.com/ionic-team/stencil/issues/3246 - although here, it's about the user of a StencilJS component, using it as a black box, so they could not leverage its lifecycle methods like componentDidRender.
- Lenguaje dominante
- TypeScript
- Estrellas
- 13.2k
- Forks
- 865
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 29
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stenciljs/core
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug(mock-doc): `Element.toggleAttribute()` is missing, so components that use it fail during SSRAbiertotriage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Stencil FOUC styles should use @layer to avoid cascade conflicts with React 19Posiblemente ocupada @johnjenkins la tomó hace 230 días. AbiertoStencil v5
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
stenciljs/core#7016 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
Los mantenedores suelen responder en 1 día
Todos los issues de stenciljs/core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AykutSarac/jsoncrack.com#616 ·
-
nip27: long hashtag swallows the rest of the content, lone # gives an empty hashtagPosiblemente ocupada @bardrop la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
nbd-wtf/nostr-tools#578 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
backnotprop/plannotator#3427 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/Power-CAT-Copilot-Studio-Kit#942 ·
Los mantenedores suelen responder en 1 día
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument pageAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AOSSIE-Org/DebateAI#801 · 1 comentario ·
Los mantenedores suelen responder en 1 día