Type handling on render request

Created on 29 May 2024, 6 months ago

Problem/Motivation

When storybook makes a render request from Drupal, it passes all arguments through php json_decode before sending off to the renderer. Arguments are automatically cast to the best fitting PHP type. In cases where your component property is a string type, but you pass a number as the input, PHP automatically assumes it should be an int/double and the renderer throws an exception.
We need to have a way for the renderer to attempt to cast incoming arguments to their defined type (if available) in the component or story definition.

An exception has been thrown during the rendering of a template ("[stat] Double value found, but a string or an object is required").

Steps to reproduce

Create a component with a string property and an associated story. The story should have a quoted integer/float as the default value on the property. Display the component in Storybook.

Proposed resolution

Load the story or referenced component somehow and provide the renderer with type definitions. Storybook has an 'argTypes' option that lets you define types for each argument, maybe we could use that.

πŸ› Bug report
Status

Active

Version

1.0

Component

Components

Created by

πŸ‡ΊπŸ‡ΈUnited States johnny5th

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024