Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular: set the @ViewChild with a non-empty value in StorybookWrapperComponent #14586

Merged
merged 1 commit into from
Apr 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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