MultiSelect inside dialog immediately closes after first click

I have provided a sample this time.

The MultiSelect control immediately closes after the first click.


Attachment: MultiselectDD_cb09cf7f.zip

1 Reply 1 reply marked as answer

SP Sureshkumar P Syncfusion Team March 31, 2022 05:19 AM UTC

Hi Gordon,


This issue is replicated because the dialog focuses on the first elements of the content area which can be active and focusable. So, we suggest you prevent this behavior by using the below code to get rid of your faced issue.


Find the code example:

<SfDialog @ref="Dialog" IsModal="true" Width="450" Visible="false">

    <DialogEvents Opened="@onOpen"></DialogEvents>

    <DialogTemplates>

        <Content>

            <SfMultiSelect TValue="string[]" TItem="Countries" Placeholder="Select countries" Mode="VisualMode.CheckBox" DataSource="@Country" ShowDropDownIcon="true" PopupHeight="250">

                <MultiSelectFieldSettings Text="Name" Value="Code"></MultiSelectFieldSettings>

            </SfMultiSelect>

        </Content>

    </DialogTemplates>

</SfDialog>

 

@code

{

    private SfDialog Dialog { get; set; }

 

    private void onOpen(OpenEventArgs args)

    {

        args.PreventFocus = true;

    }


To know more about the preventing first element focused state in the dialog component. Please refer to the documentation: https://blazor.syncfusion.com/documentation/dialog/how-to/prevent-the-focus-on-the-first-element


We have modified your provided sample based on your requirement. Find the sample in the attachment here:

Regards,

Sureshkumar P


Attachment: MultiselectDD_7cfc8b40.zip

Marked as answer
Loader.
Up arrow icon