ts4nfdi / terminology-service-suite

The SemLookP Widgets project is a collection of interactive widgets designed to ease the integration of terminology service functions into third-party applications.
https://ts4nfdi.github.io/terminology-service-suite/comp/latest/
MIT License
16 stars 2 forks source link

fix(AutocompleteWidget): show actions #77

Closed jusa3 closed 5 months ago

jusa3 commented 5 months ago

In the HTML stories, we're directly manipulating the DOM and using JavaScript to create and interact with widgets. When we define selectionChangedEvent as a function that does nothing (() => {return;}), we're essentially providing a placeholder for the event handler. This is necessary because the HTML widget expects a function to be passed as the selectionChangedEvent handler. If we don't provide a function, the widget might not initialize correctly or might not behave as expected when an event occurs.

In contrast, React stories are more integrated with Storybook's React environment, which includes support for actions. When we define an action in the story's argTypes, Storybook automatically creates a function that logs the event to the Storybook UI. This is why we don't need to explicitly define selectionChangedEvent as a function in the React stories. Instead, we define it in argTypes like so:

argTypes: {
 selectionChangedEvent: { action: 'selectionChangedEvent' },
},

This tells Storybook to create an action for selectionChangedEvent, which will be called with the event data whenever the event occurs in the component. This is a feature of Storybook's React environment and is not applicable to plain HTML widgets.

I separated AutocompleteWidgetStoryArgs (providing the function) and AutocompleteWidgetStoryArgsReact (not providing a function) and passed them to the corresponding HTML and React stories.

jusa3 commented 5 months ago

:tada: This PR is included in version 1.22.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: