Add a Title Formatter

Created on 27 August 2024, 8 months ago

Problem/Motivation

Split out from โœจ Add formatters and other mechanisms as alternative to base fields directly in entity templates Active .

Proposed resolution

Create a TitleFormatter, copying code from Manage Display module. It should be fine with minimal changes.

Write a test.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

โœจ Feature request
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Fieldย  โ†’

Last updated about 23 hours ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @adamps
  • First commit to issue fork.
  • Merge request !9341issue/3470497: Added title formatter. โ†’ (Open) created by pooja_sharma
  • Pipeline finished with Failed
    8 months ago
    Total: 225s
    #266208
  • Assigned to pooja_sharma
  • Added title formatter as mentioned in proposed solution , this 'll add title formatter for plain type field for manage display , working on test coverage part in which cover if title formatter selected for field type , then it linked to title or not.on the basis of selected config.

  • Pipeline finished with Success
    8 months ago
    Total: 772s
    #266931
  • Pipeline finished with Success
    7 months ago
    Total: 711s
    #267255
  • Pipeline finished with Success
    7 months ago
    Total: 540s
    #267269
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • Added title formatter as mentioned in proposed solution & added test coverage as well for title formatter, apart form nothing seems to be left.

    PLease review, moving NR

  • Pipeline finished with Failed
    7 months ago
    Total: 475s
    #267279
  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Saw this one early, left some comments.

  • Assigned to pooja_sharma
  • Pipeline finished with Success
    7 months ago
    Total: 473s
    #267295
  • Pipeline finished with Success
    7 months ago
    Total: 488s
    #267993
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • Addressed the feedback, left one comment on MR. PLease review, moving NR.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Responded to comment

  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Will also need change record.

  • Assigned to pooja_sharma
  • Thanks for reviewing. working on the feedback.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Nice to work on issues in the Modernization effort ๐ŸŒฑ [meta] Drupal modernization Active . Thanks!

    This is changing the UI so adding Usability tag. As a new form this should have a Usability review as well, so adding that tag. And screenshots available from the issue summary.

  • Pipeline finished with Failed
    7 months ago
    Total: 2241s
    #269196
  • Pipeline finished with Success
    7 months ago
    Total: 1253s
    #269230
  • Pipeline finished with Success
    7 months ago
    Total: 499s
    #271508
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Code wise don't see anything but leave in review for usability

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mradcliffe USA

    Could a site builder end up creating a situation where they set the sub title to use h2 and then the hierarchy no longer matches between teaser and page views?

    - Page
    - h1: Node Title via page-title
    - h2: Sub title
    - Teaser
    - h1: Page title
    - h2: Node title
    - h2: Sub title

  • Could a site builder end up creating a situation where they set the sub title to use h2 and then the hierarchy no longer matches between teaser and page views?

    - Page
    - h1: Node Title via page-title
    - h2: Sub title (Default form mode)
    - Teaser
    - h1: Page title
    - h2: Node titlender
    - h2: Sub title or h3: Sub title (whatever selected in tag of title formatter in specific form mode like here teaser, 'll render on FE)

    Yes I have verified it is possible, correct me if I 'm missing anything.

  • I am not able to reproduce issue , not getting Title dropdown

    Steps to followed
    1. Added Plain text filed in Article.
    2. Configured in manage display , not getting title Drop down in Format column fort "Title".
    3. Adding screenshot for reference.

  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland sokru

    +1 for adding this feature, so it would make easier to land the parent issue.
    Left suggestion also to add H6 -level element.

    I assume #18 was missing a cache clearance.

  • Pipeline finished with Canceled
    7 months ago
    Total: 67s
    #280986
  • Pipeline finished with Success
    7 months ago
    Total: 746s
    #280987
  • Status changed to RTBC 7 months ago
  • h6 tag by mistaken missed added back, Please review moving NR (usability review tag)

  • Status changed to Needs review 7 months ago
  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States benjifisher Boston area

    Usability review

    We discussed this issue at ๐Ÿ“Œ Drupal Usability Meeting 2024-09-13 Needs work . That issue has a link to a recording of the meeting.

    For the record, the attendees at the usability meeting were @AaronMcHale, @benjifisher, @rkoller, @shaal, @simohell, @worldlinemine, and @zetagraph.

    We like the idea of giving site builders more flexibility in how plain-text fields are displayed. Once the parent issue is done, it will be much easier for site builders to create a consistent heading hierarchy, which will be a big a11y improvement.

    Our main recommendation is that we improve the existing (default) formatter for plain-text fields instead of adding a new one. That is, add the select list of tags to the existing formatter. I read the comments on this issue and on the parent issue, and I did not see any discussion of this option. Is there any reason to have a separate formatter?

    For backwards compatibility, we will have to add an option (for example, - none -) and make that the default.

    A minor advantage of improving the existing formatter is that we do not have to decide how to name (or label) the new one. Naming things is hard, and it is generally best to name things after what they do. The proposed label in this issue is "Title", which is how you expect to use it rather than a description of what it does.

    Our other recommendations are

    1. Use "Display as" as the label for the select list.
    2. Remove the description field (help text). In general, we try to make our labels clear enough that we do not need help text.
    3. In the summary description, use "Displayed as โ€ฆ". This will be more consistent with the existing text "Linked to the Content".

    Once this issue is implemented, people are likely to ask for additional options: <p> and <code> and so on. This seems like a good idea for a follow-up issue: either a hook that modules can implement or some global configuration that site builders can choose in order to change the list of available tags.

    If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.

  • Assigned to pooja_sharma
  • Thanks for reviewing it, I agree , we can simply enhance the existing formatter rather than introducing new one. In proposed solution section written

    Create a TitleFormatter

    so I thought need create one.

    I believe along with one mentioned feedback need upgrade path as well , as we are enhancing existing formatter. correct me I 'm missing anything that needs to be taken care.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mortona2k Seattle

    I would not mind being able to select a tag for the plain text formatter to do this. But what about setting a class, or settings for field/wrapper elements? I am thinking of the Fences module.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States benjifisher Boston area

    @poojah_sharma:

    If the default "none" option is represented in the database as no entry (as opposed to an entry of "none") then I am not sure we need an upgrade path. At least, if "upgrade path" means an update (or post-update) function.

    In proposed solution section written ... so I thought need to create new one.

    Any issue on d.o is a cooperative effort. We often think of better solutions before an issue is fixed, so do not assume that the current proposed resolution is the final one. If you have a better idea, then suggest it. Since we are changing the resolution, we should update that section of the issue summary. I am adding the tag for that. I probably should have done that with my previous comment.

    @mortona2k:

    I am also a fan of the Fences module โ†’ , and we looked at it during the usability meeting. But let's not expand the scope of this issue to include everything that Fences provides. The current scope is enough to advance the parent issue. If you want all the features of Fences, then install it, and if you think that should be part of core then open a new issue to discuss it.

    In fact, once the parent issue is fixed, you should be able to install the Fences module and then add CSS classes to your node titles (and not just nodes).

  • Pipeline finished with Failed
    7 months ago
    Total: 1130s
    #284645
  • Pipeline finished with Success
    7 months ago
    Total: 600s
    #284665
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • @benjifisher, I missed the point, like better solution is to add same tag in existing formatter instead of creating new one, thanks for the feedback, 'll try to keep address these points as well.

    Try to addressed the requested changes , update issue summary as well. as we have used '-None- as by default so when I try save entity from "manage form" page then is no any error encountered , I guess no need to add upgrade path as well.

    PLease review, moving NR.

  • Status changed to RTBC 7 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    I am happy with the idea to extend the existing formatter rather than create a new one. In the manage display module we can create a migration from TitleFormatter.

    The new code looks good to me thanks.

  • Pipeline finished with Failed
    7 months ago
    #286545
  • Status changed to Needs review 7 months ago
  • Added test coverage in existing kernel test instead of creating new test from performance perspective.

    Please review, moving NR.

  • Pipeline finished with Success
    7 months ago
    Total: 825s
    #286549
  • Pipeline finished with Success
    7 months ago
    Total: 605s
    #286566
  • Resolving conflicts, verifying functionality

  • Pipeline finished with Failed
    6 months ago
    Total: 158s
    #296169
  • Pipeline finished with Failed
    6 months ago
    Total: 84s
    #296171
  • Pipeline finished with Canceled
    6 months ago
    Total: 95s
    #296172
  • Pipeline finished with Success
    6 months ago
    Total: 916s
    #296173
  • Resolved MR conflicts, functionality seems working fine.

    Please review , moving NR.

  • Hi,
    Changes has been verified in the issue fork branch. working has expected to the branch.
    Before Branch:

    After: Branch:

    But the patch 9341.patch is failing in the Drupal 11.x branch. Please find the screenshot for the more understanding.

  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland sokru

    I think all threads should be resolved now.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States shaal Boca Raton, FL
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Issue credits, including those from UX meeting
    Crediting @manibharathi ezhimalai ravi for manual testing

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    This is a great feature. We need to add an upgrade path.

    This should take the form of a post update hook that makes use of the config entity updater.

    There should also be a test that asserts the value isn't set before running update, and then checking it is set.

    There's a good example of a similar update hook (also for entity view displays) here https://git.drupalcode.org/project/drupal/-/merge_requests/10002/diffs#2...

    This MR also contains a good example of an upgrade path test - https://git.drupalcode.org/project/drupal/-/merge_requests/10002/diffs#2...

    Unfortunately it doesn't look like there are any instances of this formatter in use in the standard profile, so that means you will have to create a new database dump/fixture file. \Drupal\Tests\views\Functional\Update\EntityArgumentUpdateTest in core has an example of how to add additional test fixtures to the default standard dump.

    The docs have more information on how you can do that - https://www.drupal.org/docs/drupal-apis/update-api/writing-automated-upd... โ†’

  • @larowlan, Thanks for reviewing , working on it

  • Assigned to pooja_sharma
  • Status changed to Needs work about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mradcliffe USA

    I fixed a typo and changed the resolution from being a question to a statement in the proposed resolution that made it difficult for me to understand without reading the code.

Production build 0.71.5 2024