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

Button focus() enhancements #1830

Closed
ryanbmarx opened this issue Oct 20, 2023 · 2 comments · Fixed by #1878
Closed

Button focus() enhancements #1830

ryanbmarx opened this issue Oct 20, 2023 · 2 comments · Fixed by #1878

Comments

@ryanbmarx
Copy link
Contributor

Currently, Button.svelte does not forward focus events. Adding on:focus to the element would solve this.

Also, to programmatically assign focus, access to the HTML element is required, but currently the Button component does not allow access. Perhaps this would work:

export let el: HTMLElement;

<button bind:this={el}

Which would allow buttonInstance.el.focus() in parent components.

I'm happy to generate a PR if these approaches are acceptable.

@metonym
Copy link
Collaborator

metonym commented Oct 20, 2023

Note that the Button does support programmatic focus via the ref prop:

<script>
  import { Button } from "carbon-components-svelte";

  let ref;

  $: ref?.focus();
</script>

<Button bind:ref>Primary button</Button>

However, I do think that forwarding focus to button events is reasonable. A PR would be welcome.

@metonym
Copy link
Collaborator

metonym commented Jan 10, 2024

Fixed in v0.82.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants