Skip to content

Commit

Permalink
chore: fix withOnyxVModelDecorator storybook decorator never matchi…
Browse files Browse the repository at this point in the history
…ng (#1996)

The filter logic of the `withOnyxVModelDecorator` was incorrect and
never matched. This is fixed now by checking for the specific prop and
checking its default value.
  • Loading branch information
JoCa96 authored Oct 25, 2024
1 parent b48f2a8 commit 154995c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/sit-onyx/.storybook/vModel.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { withVModelDecorator } from "@sit-onyx/storybook-utils";
import type { StrictInputType } from "storybook/internal/types";

const isManaged = (argType: StrictInputType) =>
argType.table?.defaultValue?.summary === "MANAGED_SYMBOL";

/**
* Custom `withVModelDecorator` filter function, because we want don't want to override values that are managed.
*/
export const withOnyxVModelDecorator = withVModelDecorator({
filter: ({ table, name }, _, array) => {
filter: ({ table, name }, _, argTypes) => {
if (table?.category !== "events" || !name.startsWith("update:")) return false;
const propName = name.replace(/^update:/, "");
return array.every(
(argType) =>
argType.name !== propName && argType.table?.defaultValue?.summary !== "MANAGED_SYMBOL",
);
return !argTypes.some((argType) => argType.name === propName && isManaged(argType));
},
});

0 comments on commit 154995c

Please sign in to comment.