Skip to content

Commit

Permalink
Merge pull request #14586 from storybookjs/angular/fix-StorybookWrapp…
Browse files Browse the repository at this point in the history
…erComponent

Angular: set the @ViewChild with a non-empty value in StorybookWrapperComponent
  • Loading branch information
shilman committed Apr 23, 2021
1 parent 18ac134 commit b63e6ba
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ const getNonInputsOutputsProps = (
*/
export const createStorybookWrapperComponent = (
template: string,
storyComponent: Type<unknown>,
storyComponent: Type<unknown> | undefined,
styles: string[],
initialProps?: ICollection
): Type<any> => {
// In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
// storyComponent was not provided.
const viewChildSelector = storyComponent ?? '__storybook-noop';

@Component({
selector: RendererService.SELECTOR_STORYBOOK_WRAPPER,
template,
Expand All @@ -52,9 +56,9 @@ export const createStorybookWrapperComponent = (

private storyWrapperPropsSubscription: Subscription;

@ViewChild(storyComponent ?? '', { static: true }) storyComponentElementRef: ElementRef;
@ViewChild(viewChildSelector, { static: true }) storyComponentElementRef: ElementRef;

@ViewChild(storyComponent ?? '', { read: ViewContainerRef, static: true })
@ViewChild(viewChildSelector, { read: ViewContainerRef, static: true })
storyComponentViewContainerRef: ViewContainerRef;

// Used in case of a component without selector
Expand Down

0 comments on commit b63e6ba

Please sign in to comment.