rickbutterfield / Umbraco.Community.BlockPreview

Easy to use rich HTML backoffice previews for the Umbraco Block List and Block Grid editors.
MIT License
19 stars 11 forks source link

Live editing causing flickering #55

Closed bielu closed 1 month ago

bielu commented 5 months ago

Which Umbraco.Community.BlockPreview version are you using?

1.8.4

Which Umbraco version are you using? For example: 10.4.0 - don't just write v10

13.2.2

Bug summary

When editing block with live editing enabled it will cause flickering of editor in background.

Steps to reproduce

Add few blocks to block grid modify one (best example when rte is in) and see editor in background is flickering

Expected result / actual result

Editors post loading are not flickering but updating with required changes.

bielu commented 5 months ago

@rickbutterfield I have investigated it and it could be solved easily by changing:

function loadPreview(content, settings) {
      $scope.markup = $sce.trustAsHtml('<div class="preview-alert preview-alert-info">Loading preview</div>');
      $scope.loading = true;

      var formattedBlockData = {
        layout: $scope.block.layout,
        contentData: [content || $scope.block.data],
        settingsData: [settings || $scope.block.settingsData]
      };

      previewResource.getPreview(formattedBlockData, $scope.id, $scope.blockEditorAlias, $scope.model.constructor.name == 'BlockGridBlockController', $scope.language).then(function (data) {
        $scope.markup = $sce.trustAsHtml(data);
        $scope.loading = false;
      });
    }

    loadPreview($scope.block.data, $scope.block.settingsData);

to

function loadPreview(content, settings) {
      var formattedBlockData = {
        layout: $scope.block.layout,
        contentData: [content || $scope.block.data],
        settingsData: [settings || $scope.block.settingsData]
      };

      previewResource.getPreview(formattedBlockData, $scope.id, $scope.blockEditorAlias, $scope.model.constructor.name == 'BlockGridBlockController', $scope.language).then(function (data) {
        $scope.markup = $sce.trustAsHtml(data);
        $scope.loading = false;
      });
    }
    $scope.markup = $sce.trustAsHtml('<div class="preview-alert preview-alert-info">Loading preview</div>');
    $scope.loading = true;
    loadPreview($scope.block.data, $scope.block.settingsData);
rickbutterfield commented 1 month ago

Hey @bielu! This was released in 1.9.0, so that or any newer versions will have a fix in!