mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(radio-button): forward focus
, blur
events (#2135)
As identified in #2131, `focus` and `blur` events should be forwarded to the underlying `RadioButton` element.
This commit is contained in:
parent
dd1338ffc4
commit
1462e300d6
6 changed files with 26 additions and 3 deletions
|
@ -2966,6 +2966,8 @@ None.
|
||||||
|
|
||||||
| Event name | Type | Detail |
|
| Event name | Type | Detail |
|
||||||
| :--------- | :-------- | :----- |
|
| :--------- | :-------- | :----- |
|
||||||
|
| focus | forwarded | -- |
|
||||||
|
| blur | forwarded | -- |
|
||||||
| change | forwarded | -- |
|
| change | forwarded | -- |
|
||||||
|
|
||||||
## `RadioButtonGroup`
|
## `RadioButtonGroup`
|
||||||
|
|
|
@ -11389,6 +11389,16 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"events": [
|
"events": [
|
||||||
|
{
|
||||||
|
"type": "forwarded",
|
||||||
|
"name": "focus",
|
||||||
|
"element": "input"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "forwarded",
|
||||||
|
"name": "blur",
|
||||||
|
"element": "input"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "forwarded",
|
"type": "forwarded",
|
||||||
"name": "change",
|
"name": "change",
|
||||||
|
|
|
@ -71,6 +71,8 @@
|
||||||
required={$groupRequired ?? required}
|
required={$groupRequired ?? required}
|
||||||
{value}
|
{value}
|
||||||
class:bx--radio-button={true}
|
class:bx--radio-button={true}
|
||||||
|
on:focus
|
||||||
|
on:blur
|
||||||
on:change
|
on:change
|
||||||
on:change={() => {
|
on:change={() => {
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -26,6 +26,12 @@
|
||||||
{id}
|
{id}
|
||||||
{name}
|
{name}
|
||||||
{ref}
|
{ref}
|
||||||
|
on:focus={() => {
|
||||||
|
console.log("focus");
|
||||||
|
}}
|
||||||
|
on:blur={() => {
|
||||||
|
console.log("blur");
|
||||||
|
}}
|
||||||
on:change={() => {
|
on:change={() => {
|
||||||
console.log("change");
|
console.log("change");
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -91,8 +91,7 @@ describe("RadioButton", () => {
|
||||||
expect(consoleLog).toHaveBeenCalledWith("change");
|
expect(consoleLog).toHaveBeenCalledWith("change");
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO(bug): forward focus/blur events.
|
it("should handle focus and blur events", async () => {
|
||||||
it.skip("should handle focus and blur events", async () => {
|
|
||||||
const consoleLog = vi.spyOn(console, "log");
|
const consoleLog = vi.spyOn(console, "log");
|
||||||
render(RadioButton);
|
render(RadioButton);
|
||||||
|
|
||||||
|
|
6
types/RadioButton/RadioButton.svelte.d.ts
vendored
6
types/RadioButton/RadioButton.svelte.d.ts
vendored
|
@ -71,6 +71,10 @@ export type RadioButtonProps = Omit<$RestProps, keyof $Props> & $Props;
|
||||||
|
|
||||||
export default class RadioButton extends SvelteComponentTyped<
|
export default class RadioButton extends SvelteComponentTyped<
|
||||||
RadioButtonProps,
|
RadioButtonProps,
|
||||||
{ change: WindowEventMap["change"] },
|
{
|
||||||
|
focus: WindowEventMap["focus"];
|
||||||
|
blur: WindowEventMap["blur"];
|
||||||
|
change: WindowEventMap["change"];
|
||||||
|
},
|
||||||
{ labelText: {} }
|
{ labelText: {} }
|
||||||
> {}
|
> {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue