Skip to content

[Blazor] Optional constraint to component nesting (UI warning/Compilation error) #31175

Closed
@rafaelchampion

Description

@rafaelchampion

In DevExpress they have a nice touch to their components where:

  • Sub-components may only be nested within a specific parent component
  • A parent component may only nest a defined list of components

This is shown as an UI warning much like when you try to nest a 'div' inside an 'ul'.

E.g.:

In the ASPxGridView component, Columns is a valid nestable child component:

<dx:ASPxGridView runat="server">
      <Columns></Columns>
</dx:ASPxGridView>

In comparison, if we try to nest an Items component (nestable within other components like ASPxComboBox, but not within ASPxGridView) or any other component/tag, like this:

<dx:ASPxGridView runat="server">
        <Items></Items>
</dx:ASPxGridView>

The UI displays a warning: Element 'Items' not supported.

Similarly, it's not possible to use a standalone Columns component outside an ASPxGridView component.

It would be nice to be able to:

  • Declare a specific list of components to be nestable inside a parent component
    and/or
  • Specify that a component may only be usable if nested inside a specific component/list of components

This allows a child component to only be used where it's strictly intended to be used, like if you have events that require a determined component tree to work and also creates a failproof use of a determined component.

For example if I have a card-list component and a card-list-item component with a delete button and I want the card-list-item component to be strictly nestable inside a card-list component so when I click the delete button an event is always fired in the parent component.

I know it's not an ultra required feature but it would be nice to have.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions