Skip to content

Teaser Component Link field not editable in XPM #21

@bkoopman

Description

@bkoopman

Inline editing a Teaser Component Link field is not possible, the field is selectable and the breadcrumb seems to indicate we are on the actual field, but there is no slide out opening to select a different Component.

in .NET on the Teaser.cshtml view we do the following:

<a class="@linkStyle" href="@Model.Link.Url" title="@Model.Link.AlternateText" @Html.DxaPropertyMarkup(() => Model.Link)>
    @(Model.Link.LinkText ?? Html.Resource("core.readMoreLinkText"))
    @if (!isButton)
    {
        <i class="fa fa-chevron-right"></i>
    }
</a>

This generates the XPM markup inside the <a> tag (which is incorrect, for XPM it needs to always be generated outside of the <a> tag, and inside a <span> or <div> tag).

But more importantly @Html.DxaPropertyMarkup(() => Model.Link) is on the wrong field, it uses Model.Link (which is a reference to the embedded Schema field), and should use Model.Link.Url (which is a reference to the internalLink field of the embedded Schema, containing the actual Component link).

For DXA.NET the solution for the Teaser view is:

<span @Html.DxaPropertyMarkup(() => Model.Link.Url)>
    <a class="@linkStyle" href="@Model.Link.Url" title="@Model.Link.AlternateText">
        @(Model.Link.LinkText ?? Html.Resource("core.readMoreLinkText"))
        @if (!isButton)
        {
            <i class="fa fa-chevron-right"></i>
        }
    </a>
</span>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions