ampproject / ampproject/amp-wp

Search block with "button only" configuration is broken

Open
#7,677 0 comments 0 reactions 1 assignee Claimed by @thelovekesh View on GitHub
Bug P1
Dominant language
PHP
Stars
1.8k
Forks
378
Avg merge
1d 15h
Merged PRs (30d)
10

Description

### 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](https://github.com/ampproject/amp-wp/assets/134745/8f5ffaec-9d0e-4bf4-bc1f-80defce3c110)

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

2 validation errors

```json
[
{
"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](https://github.com/ampproject/amp-wp/assets/134745/1c26e041-ea4e-4e2f-8835-4911a53bfab3)

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.