Skip to content

Page fails to load using MatAutocompleteList inside MatDialog EditForm #430

@tkennedy13

Description

@tkennedy13

I am trying to use an MatAutocompleteList on a dialog edit form and the page crashes every time with the following errors showing in the dev console.

image

I copied the code from the sample into the root of my page and tried

<MatAutocompleteList Items="@options2" TItem="Car" Label="Select car" CustomStringSelector="@(i => i.Name)" @bind-Value="@value" />

and

<MatAutocompleteList Items="@options2" TItem="Car" Label="Select car" CustomStringSelector="@(i => i.Name)" @bind-Value="@value">
     <ItemTemplate>
         <div style="display: flex; flex-direction: row; width: 100%;">
              <div style="flex: 1;">@context.Name</div>
             <div style="width: 150px;">@context.Price$</div>
        </div>
    </ItemTemplate>
</MatAutocompleteList>

and both autocomplete's loaded. When I put the same code inside of a

<MatDialog @bind-IsOpen="@dialogIsOpen">
	<MatDialogTitle>Create</MatDialogTitle>
	<MatDialogContent>
		<EditForm Model="@obj" OnValidSubmit="@CreateObj">
			<DataAnnotationsValidator />
			<ValidationSummary /> 
			<MatAutocompleteList Items="@options2" TItem="Car" Label="Select car" CustomStringSelector="@(i => i.Name)" @bind-Value="@value" />
		</EditForm>
	</MatDialogContent>
	<MatDialogActions>
		<MatButton OnClick="@(e => { dialogIsOpen = false; })">Cancel</MatButton>
		<MatButton OnClick="@CreateObj">Create </MatButton>
	</MatDialogActions>
</MatDialog>

it consistently gives the above referenced errors and the razor page will not load.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions