Problem/Motivation

The Style for the marker of a new comment looks like the content of the comment. Needs to diminished importance and/or highlight the marker to distinguish it from the body of the comment.

comments new issue

Proposed resolution

Add CSS to style the bartik new comment marker. Use theme_mark to keep the markup consistent

Remaining tasks

Implement theme_mark in a patch
Review

User interface changes

Comment new marker style to distinguish change from body copy

API changes

n/a

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LewisNyman’s picture

Issue tags: +frontend
natanmoraes’s picture

Assigned: Unassigned » natanmoraes
natanmoraes’s picture

Assigned: natanmoraes » Unassigned
Status: Active » Needs review
FileSize
363 bytes

Updated the "new" mark to be highlighted in red.

okami’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
206.89 KB

I applied the patch and added a comment field, then added a comment and saw the styled new text.

I think this fixes the issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Let's use theme_mark here. And then this will be consistent with how the node "new" is marked up.

LewisNyman’s picture

Issue summary: View changes
Issue tags: -Novice
natanmoraes’s picture

What do you guys mean by "use theme_mark"? Isn't the "new" mark being rendered properly already?

star-szr’s picture

theme_mark() is now mark.html.twig (things can move fast around here). What @alexpott is saying is that the "new" marker for comments should use our standard mark theme hook/template rather than its own custom markup. Then likely no CSS changes would be needed.

lauriii’s picture

After changing rendering method I couldn't find any changes on the layout.

teroelonen’s picture

Assigned: Unassigned » teroelonen
teroelonen’s picture

Status: Needs work » Needs review
FileSize
1.61 KB
50.22 KB

Merged both patches and created an other one. Screenshot of the result:

Status: Needs review » Needs work

The last submitted patch, 11: new-comments-in-bartik-highlight-2277643-11.patch, failed testing.

lauriii’s picture

Status: Needs work » Needs review
FileSize
6.45 KB
lauriii’s picture

This patch also removes deprecated Javascript file.

star-szr’s picture

Quick drive by review, thanks @lauriii and @teroelonen for jumping on this one. I think the last point is the most important at this time, we need an answer there - maybe there is automated test coverage somewhere for that?

  1. +++ b/core/modules/comment/comment.module
    @@ -1351,6 +1351,12 @@ function template_preprocess_comment(&$variables) {
    +  $mark = array(
    +    '#theme' => 'mark',
    +    '#status' => comment_mark($comment->getCommentedEntityId(), $comment->getCreatedTime()),
    +  );
    +  $variables['new'] = drupal_render($mark);
    

    Try setting the variable as a render array here, there shouldn't be a need to pre-render it.

    $variables['new'] = array('#theme' => 'mark')

  2. +++ b/core/modules/comment/comment.module
    @@ -1358,6 +1364,33 @@ function template_preprocess_comment(&$variables) {
    +function comment_mark($nid, $timestamp) {
    +
    +  $cache = &drupal_static(__FUNCTION__, array());
    

    Extra blank line here.

  3. +++ b/core/modules/comment/templates/comment.html.twig
    @@ -67,12 +67,7 @@
    -  {#
    -  Hide the "new" indicator by default, let a piece of JavaScript ask
    -  the server which comments are new for the user. Rendering the final
    -  "new" indicator here would break the render cache.
    -  #}
    -  <mark class="hidden new" data-comment-timestamp="{{ new_indicator_timestamp }}"></mark>
    

    Wait a minute, can we be sure this doesn't break caching? And if that's not a problem, what's happening to the new_indicator_timestamp variable?

lauriii’s picture

Actually I've been testing this manually already for a while, and because of comments are cached, so is the new marker also.

And because by manually testing this seems to be broken, I'm not sure if there's automated testing coverage for that because automated tests seems to pass.

star-szr’s picture

Oh I guess we don't have automated testing because JavaScript. Doh.

LewisNyman’s picture

Status: Needs review » Needs work

Setting to needs work based on #15

lauriii’s picture

Assigned: teroelonen » Unassigned
Issue tags: +Needs issue summary update

This needs issue summary update because whats described there isn't relevant anymore. I guess we have to stick with the javascript solution to not break caching.

andypost’s picture

andypost’s picture

andypost’s picture

+++ b/core/modules/comment/comment.module
@@ -1351,6 +1351,12 @@ function template_preprocess_comment(&$variables) {
+    '#status' => comment_mark($comment->getCommentedEntityId(), $comment->getCreatedTime()),
...
+  $variables['new'] = drupal_render($mark);

this is no go now, so JS is a way

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.