telekom / scale

Scale is the digital design system for Telekom products and experiences.
https://telekom.github.io/scale/
Other
375 stars 82 forks source link

Modal does not receive focus, if opened = true before modal element connects #2058

Open goatfryed-holos opened 1 year ago

goatfryed-holos commented 1 year ago

Scale Version 3.0.0-beta.136

Framework and version Base Scale Components

Current Behavior If the modal is rendered with opened attribute, the modal does not receive focus as expected.

Expected Behavior The modal opens, the first interactable element is focused and a focus trap is activated.

Code Reproduction [Code Sandbox|https://codesandbox.io/p/sandbox/wispy-water-dm7kxl]

Desktop (please complete the following information):

EDIT: Update scale version

goatfryed-holos commented 1 year ago

In frameworks, you often manage the open/close on a higher component level within your project, which makes this a usual use case. Vue users can use the following workaround

const modalOpened = ref(false);
onMounted(() => customElements.whenDefined('scale-modal').then(() => modalOpened.value = true))