Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: focus lost when element added to the right of an array #6033

Open
3 tasks done
KotlinIsland opened this issue Oct 19, 2024 · 0 comments
Open
3 tasks done

bug: focus lost when element added to the right of an array #6033

KotlinIsland opened this issue Oct 19, 2024 · 0 comments
Labels

Comments

@KotlinIsland
Copy link

Prerequisites

Stencil Version

@stencil/core@4.22.1

Current Behavior

when a render occurs and an element is removed from the start of an array, and another element is added to the end. then the elements that don't change within the array lose focus. i think it's because they are removed from the dom, then added back

when clicking "show left":

image

when clicking "show right":

image

why are all the elements highlighted? only the newly added "right" element should be appeared

Expected Behavior

it doesn't lose focus

System Info

happens on chrome and firefox

      System: node 20.6.1
    Platform: windows (10.0.19045)
    Compiler: C:\Users\AMONGUS\projects\stencil-test\node_modules\@stencil\core\compiler\stencil.js
       Build: 1728498324
     Stencil: 4.22.1
  TypeScript: 5.5.4
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

run:

add some css so you can see the outline when focused:

button:focus {
  outline: 2px solid black;
}
import { Component, h, State } from '@stencil/core';

@Component({
  tag: 'my-component',
  styleUrl: 'my-component.css',
})
export class MyComponent {
  @State() add?: "left" | "right" = "left"
  render() {
    const button = (value: string, onclick?: () => void) => <button
      key={value} value={value} onClick={onclick}>{value}
    </button>

    return [
      this.add === "left" ? button("left") : null,
      button("show left", () => this.add = "left"),
      button("show right", () => this.add = "right"),
      this.add === "right" ? button("right") : null,
    ]
  }
}

Code Reproduction URL

see "Steps to Reproduce"

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Oct 19, 2024
@KotlinIsland KotlinIsland changed the title bug: focus lost when bug: focus lost when element added to the right of an array Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
@KotlinIsland and others