Label change does not update machine name automatically when creating new search pages

Created on 24 April 2025, 21 days ago

Problem/Motivation

When adding a new search page at /admin/config/search/pages, the "Label" field is used to auto-fill the machine name. However, if a user changes the label after the initial autofill, the machine name does not update accordingly. This behavior is inconsistent with other places in the core (e.g., content types, menus), where the machine name updates automatically as long as it has not been manually edited.

Steps to reproduce

  • Navigate to /admin/config/search/pages.
  • Select a page type (Content, Help, or Users) under "Search page type".
  • Observe that the "Label" field is autofilled based on the selected page type and the machine name is generated accordingly.
  • Change the "Label" field.
  • Notice that the machine name does not update to reflect the new label.
  • The only way to update the machine name is to click "Edit" next to the machine name field and manually enter it.

Proposed resolution

Update the behavior to ensure that the machine name field continues to sync with the label field, unless the machine name has been manually edited. This would make the experience consistent with other parts of Drupal core.

Remaining tasks

Identify the form and field components responsible for this behavior.

User interface changes

The machine name field under the search page creation will dynamically update when the label is changed (unless manually edited).

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

search.module

Created by

🇮🇳India prashant.c Dharamshala

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

Merge Requests

Comments & Activities

  • Issue created by @prashant.c
  • Merge request !11931Conditional default value for label → (Open) created by prashant.c
  • 🇮🇳India prashant.c Dharamshala
  • Pipeline finished with Failed
    21 days ago
    Total: 454s
    #481166
  • 🇺🇸United States smustgrave

    Thanks for reporting, can we add a test case showing the bug

  • 🇮🇳India prashant.c Dharamshala

    Attempted to write the test, needs to be reviewed.

  • Pipeline finished with Failed
    20 days ago
    Total: 133s
    #481370
  • Pipeline finished with Failed
    20 days ago
    Total: 466s
    #481386
  • 🇺🇸United States smustgrave

    Seems to have test failures

  • Pipeline finished with Canceled
    20 days ago
    Total: 133s
    #481714
  • Pipeline finished with Success
    20 days ago
    Total: 1492s
    #481715
  • 🇮🇳India prashant.c Dharamshala
  • 🇺🇸United States smustgrave

    Instead of its own file and own test is there not an existing test that could be expanded

  • 🇮🇳India prashant.c Dharamshala

    The search module does not yet have any functional JavaScript tests. So, this is the only file for it. However, the search module has another test type, functional, kernel, and unit, where this won't fit AFAIK.

  • 🇮🇳India sagarmohite0031

    Hello,
    Tested and verified on Drupal 11,
    MR applied successfully,
    and working as expected "machine name is generated accordingly."

    Steps to reproduce-
    Navigate to /admin/config/search/pages.
    Select a page type (Content, Help, or Users) under "Search page type".
    Observe that the "Label" field is autofilled based on the selected page type and the machine name is generated accordingly.
    Change the "Label" field.
    Notice that the machine name does not update to reflect the new label.
    The only way to update the machine name is to click "Edit" next to the machine name field and manually enter it.

    Check attachments

    RTBC+

Production build 0.71.5 2024