Skip to content

Search block with "button only" configuration is broken #7677

Open
@westonruter

Description

@westonruter

Bug Description

When configuring the Search block so that the button position is set to "button only", the results is validation errors on on the AMP page and a Search button that does nothing when clicked. It should work like this:

Screen.recording.2023-11-09.09.30.30.webm

The validation errors are due to the two scripts being enqueued for the Interactivity API.

2 validation errors
[
	{
		"node_name": "script",
		"parent_name": "head",
		"code": "DISALLOWED_TAG",
		"type": "js_error",
		"node_attributes": {
			"src": "http://localhost:10003/wp-includes/js/dist/interactivity.min.js?ver=__normalized__",
			"id": "wp-interactivity-js",
			"defer": "defer",
			"data-wp-strategy": "defer"
		},
		"node_type": "ELEMENT",
		"sources": [
			{
				"type": "core",
				"name": "wp-includes",
				"file": "blocks/search.php",
				"line": 199,
				"function": "register_block_core_search",
				"hook": "init",
				"priority": 10,
				"dependency_type": "script",
				"handle": "wp-block-search-view",
				"dependency_handle": "wp-interactivity"
			},
			{
				"type": "core",
				"name": "wp-includes",
				"file": "blocks/template-part.php",
				"line": 15,
				"function": "render_block_core_template_part",
				"dependency_type": "script",
				"handle": "wp-block-search-view",
				"dependency_handle": "wp-interactivity"
			},
			{
				"type": "core",
				"name": "wp-includes",
				"file": "script-loader.php",
				"line": 659,
				"function": "wp_default_packages",
				"hook": "wp_default_scripts",
				"priority": 10,
				"dependency_type": "script",
				"handle": "wp-interactivity"
			},
			{
				"type": "core",
				"name": "wp-includes",
				"file": "blocks/file.php",
				"line": 92,
				"function": "register_block_core_file",
				"hook": "init",
				"priority": 10,
				"dependency_type": "script",
				"handle": "wp-interactivity"
			},
			{
				"type": "core",
				"name": "wp-includes",
				"file": "script-loader.php",
				"line": 2209,
				"function": "wp_print_head_scripts",
				"hook": "wp_head",
				"priority": 9
			}
		],
		"removed": true,
		"reviewed": false
	},
	{
		"node_name": "script",
		"parent_name": "head",
		"code": "DISALLOWED_TAG",
		"type": "js_error",
		"node_attributes": {
			"src": "http://localhost:10003/wp-includes/blocks/search/view.min.js?ver=__normalized__",
			"id": "wp-block-search-view-js",
			"defer": "defer",
			"data-wp-strategy": "defer"
		},
		"node_type": "ELEMENT",
		"sources": [
			{
				"type": "core",
				"name": "wp-includes",
				"file": "blocks/search.php",
				"line": 199,
				"function": "register_block_core_search",
				"hook": "init",
				"priority": 10,
				"dependency_type": "script",
				"handle": "wp-block-search-view"
			},
			{
				"type": "core",
				"name": "wp-includes",
				"file": "blocks/template-part.php",
				"line": 15,
				"function": "render_block_core_template_part",
				"dependency_type": "script",
				"handle": "wp-block-search-view"
			},
			{
				"type": "core",
				"name": "wp-includes",
				"file": "script-loader.php",
				"line": 2209,
				"function": "wp_print_head_scripts",
				"hook": "wp_head",
				"priority": 9
			}
		],
		"removed": true,
		"reviewed": false
	}
]

Expected Behaviour

Behavior on AMP page should match non-AMP page. No validation errors should occur.

Screenshots

image

PHP Version

n/a

Plugin Version

2.5.0

AMP plugin template mode

Standard, Transitional

WordPress Version

No response

Site Health

No response

Gutenberg Version

No response

OS(s) Affected

No response

Browser(s) Affected

No response

Device(s) Affected

No response

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingP1Medium priority

Type

No type

Projects

Status

To Do

Relationships

None yet

Development

No branches or pull requests

Issue actions