Problem/Motivation

Steps to "reproduce":
Add a custom basic block
Place the block in a region and save
Select to delete the block from the custom block library
UI text = This will also remove 1 placed block instance.This action cannot be undone.

Proposed resolution

Add a space between the two UI text sentences

Remaining tasks

Patch. Review. Commit.

Comments

Chris2 created an issue. See original summary.

tetranz’s picture

Status: Active » Needs review
StatusFileSize
new867 bytes

This seems like a simplistic way to do it but I don't see a better way. We have two #markup elements rendered next to each other.

chris matthews’s picture

add-a-space-2989657-2.patch seems like an ok fix to me, but leaving the status as Needs review in case someone else would like to chime in before the status is changed to RTBC.

gchauhan’s picture

Status: Needs review » Reviewed & tested by the community

Hi @tetranz, Thanks for the patch. Your patch applied successfully. This patch will add the space between two sentences at the custom basic block delete page.

longwave’s picture

Status: Reviewed & tested by the community » Needs work

I think adding the trailing space here will make translations more difficult, as they will also need to include the space.

It might be better to override getDescription() instead of buildForm() and add the message there. See e.g. MenuDeleteForm or ImageStyleDeleteForm which have similar logic in their getDescription() methods.

tetranz’s picture

Thanks @longwave. I had a feeling that wasn't the right way to go. I'll look at that in the next few days if nobody else does.

tetranz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB
new1.23 KB

This should be a little better.

I've done it slightly different to those other examples to avoid string concatenation and an unnecessary paragraph when there are no placed instances.

longwave’s picture

Title: Minor user interface text correction » Minor user interface text correction in BlockContentDeleteForm
Status: Needs review » Reviewed & tested by the community

Works as described.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: add-a-space-2989657-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

longwave’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs usability review

Combining strings like this doesn't work for translating. Sentence order can be complex.

I think we have a couple of possibilities here:
Move the $this->formatPlural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.') into a proper Drupal message ie do:

    if (!empty($instances)) {
      $this->messenger()->addWarning($this->formatPlural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'));
    }

Or we could do something like

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    $instances = $this->entity->getInstances();
    if (!empty($instances)) {
      return $this->formatPlural(count($instances), 'This will also remove 1 placed block instance. This action cannot be undone.', 'This will also remove @count placed block instances. This action cannot be undone.');
    }
    return parent::getDescription();
  }
Vidushi Mehta’s picture

Status: Needs work » Needs review
StatusFileSize
new1.19 KB

Added a patch with the above mentioned change by #11.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

We weren't really combining strings, they were two separate paragraphs and we do the same elsewhere (albeit not with sprintf). Still, #12 is functionally identical so RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

@longwave hmmm good point but I think this is the correct change because the description for the delete form is changing depending on whether additional things are going to be deleted so it makes sense to me.

Committed c0ab589 and pushed to 8.7.x. Thanks!

diff --git a/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php
index 233f3bcb04..3a77b65f65 100755
--- a/core/modules/block_content/src/Form/BlockContentDeleteForm.php
+++ b/core/modules/block_content/src/Form/BlockContentDeleteForm.php
@@ -3,7 +3,6 @@
 namespace Drupal\block_content\Form;
 
 use Drupal\Core\Entity\ContentEntityDeleteForm;
-use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Provides a confirmation form for deleting a custom block entity.

Fixed unused use on commit.

diff --git a/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php
old mode 100644
new mode 100755

The file mode shouldn't be changed by this patch. Fixed on commit.

  • alexpott committed c0ab589 on 8.7.x
    Issue #2989657 by tetranz, Vidushi Mehta, longwave, Chris2, alexpott:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.