Skip to content

bug: component's shadowRoot.delegateFocus is changed to false in SSR #618

Open
@jeeyun

Description

@jeeyun

Prerequisites

Stencil Version

4.5.23

Stencil Framework Output Target

React

Stencil Framework Output Target Version

0.8.2

Current Behavior

I have some components that use delegatesFocus. When using the library react output target with the SSR target, the component's shadowRoot.delegateFocus is changed to false. As a result I cannot programmatically call focus() on it (silently fails since the focusable element is inside the shadow).

Expected Behavior

I would expect the delegatesFocus to remain true as initially specified. This works as expected in React non-SSR scenario.

Steps to Reproduce

Create a component with delegatesFocus:

import { Component, h } from '@stencil/core';

@Component({
  tag: 'my-button',
  styleUrl: 'my-button.css',
  shadow: { delegatesFocus: true },
})
export class MyButton {
  render() {
    return (<div><button><slot></slot></button></div>);
  }
}

Consume it in React SSR app:

export function App() {
  return (
    <div>
        <MyButton>My Custom Button</MyButton>
    </div>
  );
}

Inspect MyButton component, and shadowRoot.delegatesFocus is set to false.

Image

Code Reproduction URL

https://github.com/jeeyun/nx-stencil

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanteda good issue for the communitytype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions