Short summary

extractPlainText() iterates $display->getComponents() assuming it returns fields in weight order (per the inline comment), but EntityDisplayBase::getComponents() simply returns the raw $content array as stored in config — it is never sorted by weight. The weight ordering seen in normal entity rendering only happens because EntityViewBuilder::buildMultiple() stamps #weight onto each field's render array and Drupal's render system sorts children by #weight at render time. Since TextExtractor calls viewField() directly per component instead of going through the full render pipeline, the extracted TTS text is joined in arbitrary config-array order rather than the order configured in Manage Display, so the generated audio doesn't follow the field order editors expect.

Steps to reproduce:

1. Configure a content type's tts view mode in Manage Display with several fields, setting explicit non-default weights (e.g. body before field_summary).
2. Generate TTS audio for a node of that type.
3. Observe the audio narrates fields out of the configured order.

Proposed fix: sort $display->getComponents() by weight (e.g. uasort()) before iterating in extractPlainText().

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nnevill created an issue. See original summary.

  • nnevill committed 6289c245 on 1.0.x
    fix: #3613637 TextExtractor::extractPlainText() does not order fields by...
nnevill’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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