umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.43k stars 2.67k forks source link

Inline block doesn't open when custom view has been applied #15104

Open bjarnef opened 11 months ago

bjarnef commented 11 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.3.0

Bug summary

I noticed in Block List on a current project on Umbraco 12.2.0 that when at custom view is applied, it doesn't open when inline mode is enabled. It does work with custom view when inline is NOT enabled or when inline mode is enabled and no custom view has been applied.

I think this used to work, but not totally sure.

I tested with latest changes in contrib branch as well with default starterkit.

Specifics

No response

Steps to reproduce

<style>
    .text {
        position: relative;
        display: block;
        cursor: pointer;
        background-color: transparent;
        text-align: left;
        user-select: none;
        border: none;
        padding: 0;
        height: 100%;
        padding-top: 1px;
        margin-top: -1px;
        transition: border-color 120ms, background-color 120ms;
        font-family: 'Lato';
        font-weight: 300;
        line-height: 1.5;
    }

    .text img {
        height: auto;
        max-width: 100%;
    }
</style>

<div class="text" ng-click="block.edit()" ng-focus="block.focus" ng-bind-html="block.data.richText" style="margin: 0 20px;">
</div>

https://github.com/umbraco/Umbraco-CMS/assets/2919859/2aa964c4-713b-487b-84c8-717d224c2527

Expected result / actual result

No response

github-actions[bot] commented 11 months ago

Hi there @bjarnef!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

bjarnef commented 11 months ago

Okay, after a bit of debugging I can confirm it stops here: https://github.com/umbraco/Umbraco-CMS/blob/69139eda522840a09c1b84705311542133a7c059/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/umbBlockListPropertyEditor.component.js#L472

In the other scenarios it continue.

bjarnef commented 11 months ago

It works if I copy part of the markup from inlineblock.editor.html https://github.com/umbraco/Umbraco-CMS/blob/7b0ae3c5d9d12cdefde815e7d216da1e7fa2a44a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/blocklistentryeditors/inlineblock/inlineblock.editor.html#L4

<style>
    .text {
        position: relative;
        display: block;
        cursor: pointer;
        background-color: transparent;
        text-align: left;
        user-select: none;
        border: none;
        padding: 0;
        height: 100%;
        padding-top: 1px;
        margin-top: -1px;
        transition: border-color 120ms, background-color 120ms;
        font-family: 'Lato';
        font-weight: 300;
        line-height: 1.5;
    }

    .text img {
        height: auto;
        max-width: 100%;
    }
</style>

<div class="text blockelement-inlineblock-editor"
    ng-controller="Umbraco.PropertyEditors.BlockEditor.InlineBlockEditor as vm"
    ng-class="{ '--error': parentForm.$invalid && valFormManager.isShowingValidation() }"
    style="margin: 0 20px;">
    <button type="button" class="btn-reset umb-outline blockelement__draggable-element"
            ng-click="vm.openBlock(block)"
            ng-focus="block.focus">
        <span class="caret"></span>
        <umb-icon icon="{{block.content.icon}}" class="icon"></umb-icon>
        <span class="name">{{block.label}}</span>
    </button>
    <div class="blockelement-inlineblock-editor__inner" ng-class="{'--singleGroup':block.content.variants[0].tabs.length === 1}" ng-if="block.active === true">
        <umb-element-editor-content model="block.content"></umb-element-editor-content>
    </div>
</div>

It seems block.edit() function actually only handle opening content and settings overlay.

@nielslyngsoe anyway to solve this. Alternative the custom view selected + inline mode should prompt with a warning modal or add to description the custom view isn't supported in inline mode.

nielslyngsoe commented 11 months ago

Hi @bjarnef I found my selv a bit confused when reading this issue. And then it got to me that it might be because the concepts share wordings that could lead to a misunderstanding.

so just to make sure we agree on the goal. Are you looking for an inline editing ability? Like a Block that unfolds like an accordion when clicked?

if so, that’s not a feature as it is now. The “display Inline with text” feature enables a Block to take part inside a

tag. So not inline editing but inline placement.

Please let me know if my assumptions are correct, also another wording might be appropriate to avoid such confusion.

bjarnef commented 11 months ago

Hi @nielslyngsoe

Yes, it's the inline editing, which act as accordion otherwise opens as overlay. The reason is that I have project to build a basic language picker in the navigation on frontend and the site is using the old multilingual structure with a site node per language.

image

However I then noticed nothing happens when inline mode is enabled (or custom view is used), because it stops here: https://github.com/umbraco/Umbraco-CMS/issues/15104#issuecomment-1790933280

However I could modified the view re-using the inline label controller like this: https://github.com/umbraco/Umbraco-CMS/issues/15104#issuecomment-1790976658

bjarnef commented 11 months ago

I tried if I could render some inline HTML in the label expression and use the safe_html filter, but it seems the label is always rendered as a string.

In this use-case Flag emojis could be used, although not all browsers support these.

Chrome

image

Firefox

image

There are some extensions for Chrome to fix this though. https://chrome.google.com/webstore/detail/country-flag-fixer/jhcpefjbhmbkgjgipkhndplfbhdecijh https://chrome.google.com/webstore/detail/flagmoji/bnnhpohpnamnjhajbkgpmblleljodlhd

It has been raised as an issue here, but it didn't seem to be something Chrome is fixing anytime soon: https://bugs.chromium.org/p/chromium/issues/detail?id=1209677

bjarnef commented 11 months ago

It would be nice if it was possible to configure a dynamic icon and fallback to default block icon. e.g. a different icon based on a property value, but currently it would probably require the icon to be registered among the other icons in icon picker, where uui-icon allow to inserting an inline SVG icon. https://uui.umbraco.com/?path=/docs/uui-icon--docs