goetzrobin / spartan

Cutting-edge tools powering Angular full-stack development.
https://spartan.ng
MIT License
1.35k stars 143 forks source link

Why isn't the initial value applied to the select component after cloning the repo and running Storybook? #220

Closed wizardnet972 closed 6 months ago

wizardnet972 commented 6 months ago

Please provide the environment you discovered this bug in.

I've just cloned the repository and launched Storybook. However, the initial value is not being applied to the select component. Please refer to the image provided below:

image

Reproducing this issue will be straightforward if you provide a StackBlitz template with the latest version of the repository.

Which area/package is the issue in?

select

I would be willing to submit a PR to fix this issue

wizardnet972 commented 6 months ago

It appears that writeValue is executed, and options is empty due to its laziness. const options = this.possibleOptions();

thatsamsonkid commented 6 months ago

Hmm seems we only resolved it for the reactive form but not template then in the last PR. @wizardnet972 did you want to try and fix the issue and open a PR? Otherwise I can take a look at it again, should probably add a test as well to cover this scenario

elite-benni commented 6 months ago

I think this is just an issue with the implementation of the stories. InitialValue is not really a property of the Select Component, it is only used by the story.

We are also getting errors in the console that initalValue (yes with typo ;) ) is not available for hlm-component. This is the case, because the value is set by the ControlValueAccessor, which we don't have access to in Storybook.

In the reactive form templates the initialvalue is used to set the formcontrol.