Skip to content

Clear button is search component is pressed on submit inside form #3152

@Golosay

Description

@Golosay

Hello team!

If you add a search component inside form, hitting enter will emit click event on closest button (in this case its a clear button).
As a result we can't read value from the formControl, because its cleared before submit event triggered.

We need to wrap search component into form, to enable enter hit on iOS devices. Without form iOS handle this button as return (new line).

Its a default html behaviour, if button has no type in form.

The easiest and safest fix is to add type="button" to a clear button.

How to reproduce:

<form
    class="search-form"
    (submit)="onFormSubmit($event)" // e.preventDefault() and e.stopPropagation();
  >
    <cds-search
      [autocomplete]="'off'"
      (clear)="clear()" // this event will be always triggered before submit and will always clear the value.
    ></cds-search>
  </form>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions