Open Closed

Dropdown extra property - duplicate options #9969


User avatar
0
marek.sidlo created

Hi,

I've create dropdown extra property for IdentiyUser. When I open the update dialog for user and some option is already selected for this extra property, this option is listed in dropdown 4 times (I would expect one). After clearing value, options are displayed as they should.

  • Steps to reproduce the issue:

Create a new ABP Blazor Web App

Create extra property for IdentityUser

ObjectExtensionManager.Instance.Modules()
    .ConfigureIdentity(identity =>
    {
        identity.ConfigureUser(user =>
        {
            user.AddOrUpdateProperty<string>(
                "PreferredLanguage",
                property =>
                {
                    property.UI.Lookup.Url = "/api/app/language/lookup";
                    property.UI.Lookup.DisplayPropertyName = "displayName";
                    property.UI.Lookup.ValuePropertyName = "id";
                }
            );
        });
    });

Controller method

[HttpGet]
 [Route("lookup")]
 public async Task<ListResultDto<LookupDto<string>>> GetLookupAsync()
 {
     var languages = await _languageProvider.GetLanguagesAsync();

     var items = languages
         .Select(l => new LookupDto<string>
         {
             Id = l.CultureName,
             DisplayName = l.DisplayName
         })
         .ToList();

     return new ListResultDto<LookupDto<string>>(items);
 }

Now set some value for this extra property. After that open the update dialog and click on dropdown. Four identical options will be listed in dropdown.


9 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • This issue is a known bug in ABP Framework related to dropdown extra properties for entity extension fields, where the selected value is duplicated multiple times in the dropdown when editing an entity. The root cause is in the way the lookup values are loaded and merged with the selected value in the Blazor UI.

    • The ABP team has addressed this in the following GitHub issue and pull request:

      • https://github.com/abpframework/abp/issues/18226
    • To resolve this issue, you should update your ABP Framework packages to the latest version where this bug is fixed. If you cannot upgrade immediately, a temporary workaround is to ensure your lookup endpoint does not return duplicate items and to check for duplicates in your UI logic if possible.

    • For more information on configuring dropdown extra properties, see the official documentation:

      • https://abp.io/docs/latest/framework/architecture/modularity/extending/module-entity-extensions

    This approach is confirmed by the official ABP GitHub repository and documentation.


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will check this case.

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Add MyLookupExtensionProperty service to Blazor.Client project and replace it in your Blazor and Blazor.Client modules' ConfigureServices to fix it.

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.Replace(ServiceDescriptor.Scoped(typeof(LookupExtensionProperty<,>), typeof(MyLookupExtensionProperty<,>)));
    }
    
    using Volo.Abp.BlazoriseUI.Components.ObjectExtending;
    using Volo.Abp.Data;
    
    namespace MyCompanyName.MyProjectName.Blazor.Server.Components;
    
    public class MyLookupExtensionProperty<TEntity, TResourceType> : LookupExtensionProperty<TEntity, TResourceType> where TEntity : IHasExtraProperties
    {
        protected override void OnParametersSet()
        {
            var value = Entity.GetProperty(PropertyInfo.Name);
            var text = Entity.GetProperty(TextPropertyName);
            if (value != null && text != null)
            {
                lookupItems =
                [
                    new SelectItem<object>()
                    {
                        Text = Entity.GetProperty(TextPropertyName)!.ToString()!,
                        Value = value
                    }
                ];
            }
        }
    }
    
    
  • User Avatar
    0
    marek.sidlo created

    That works, thank you.

    Do you have any estimation when this will be fixed in framework itself?

    Thanks.

  • User Avatar
    0
    marek.sidlo created

    Well, after adding this fix and some testing I'm experiencing weird behaviour.

    When I open edit dialog first time, everything works as it should. But next time it crashes with this error while opening:

    Error: System.InvalidOperationException: The render handle is already set. Cannot initialize a ComponentBase more than once.
       at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IComponent.Attach(RenderHandle renderHandle)
       at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)
       at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
       at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
       at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
       at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
       at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue(users)
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to change Scoped to Transient?

    context.Services.Replace(ServiceDescriptor.Transient(typeof(LookupExtensionProperty<,>), typeof(MyLookupExtensionProperty<,>)));

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I will fix this in the framework. Thanks.

  • User Avatar
    0
    marek.sidlo created

    Transient did the job. Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great!

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 02, 2025, 08:00