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

Issue fork drupal-3520941

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

prashant.c created an issue. See original summary.

prashant.c’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

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

prashant.c’s picture

Status: Needs work » Needs review

Attempted to write the test, needs to be reviewed.

smustgrave’s picture

Status: Needs review » Needs work

Seems to have test failures

prashant.c’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
smustgrave’s picture

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

prashant.c’s picture

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.

sagarmohite0031’s picture

StatusFileSize
new394.99 KB
new226.21 KB

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+

sagarmohite0031’s picture

Status: Needs review » Reviewed & tested by the community
larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for working on this.

The test added doesn't match the steps to reproduce in the issue summary.

The issue summary mentions that you put in an initial value and it works (which is what the test covers) but then that after you change the value it no longer works - this aspect isn't covered in the test that I can see.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Needs work » Postponed

The Search Module was approved for removal in #3476883: [Policy, no patch] Move Search module to contrib .

This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3565780: [meta] Tasks to deprecate the Search module and the removal work in #3565783: [meta] Tasks to remove the Search module.

Search will be moved to a contributed project before Drupal 12.0.0 is released.

quietone’s picture

Project: Drupal core » Search (from core)
Version: main » 1.0.0
Component: search.module » Code
Status: Postponed » Needs work

The Search Module has moved from core to contrib,