Story for Angular Material Component - Slide Toggle #17626
Unanswered
jmtt89
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i developing a storybook projects with some Angular Material components that i use on my projects.
i will creating a folder per component inside the stories folder.
When i try to create the action trigger for slide-toggle component i fond a problems..
This is my base story (just inputs)
First Try - Using argType
my first try, following the documentation was add a argType
change
andtoggleChange
(outputs from Angular Material Component)That's don't work, don't do anything, i think maybe is because y using a custom template and don't include explicit outputs on it
Second Try - Removing template (not a real solution for me)
Now toggleChange is working but change not, and printing on console
RangeError: Maximum call stack size exceeded
Third try - Add template again, this time with output and add custom props too
Same result before, this is step on right path, because i need a custom template because slide-toggle use the content of the tag for the label, and the only way to add this i fond was using custom template
Four Try - figuring out not document behaviours
Thinking over the structure of the story i figuring out the props not need to be exactly the same of the component outputs, and for how looks like the props, sure it its i can write a full function on it.
The problem is still the same, but with logs i finally understand what cause it.
onChange include the source (the component it self) in the event emitted, so when pass the event to actions callback with the component for some reason this call will be break.
The unique solution i found at this time is just send the checked attribute to action callback. if i add the source will break again.
Resulting Working File
Beta Was this translation helpful? Give feedback.
All reactions