Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Enter on filter field submits form #5790

Open
tacoWanneeJama opened this issue Oct 21, 2024 · 2 comments
Open

[Bug]: Enter on filter field submits form #5790

tacoWanneeJama opened this issue Oct 21, 2024 · 2 comments
Assignees
Labels
Type: Bug 🐞 Something isn't working
Milestone

Comments

@tacoWanneeJama
Copy link

Blazorise Version

latest

What Blazorise provider are you running on?

None

Link to minimal reproduction or a simple code snippet

When you use the [Enter] key in a search field of a DataGrid, the whole webpage is submitted and refreshed.
This only happens hen only 1 seachfield is present in the grid. When more textual searchfield are present(even hidden) this unwanted behavior is not present.

Steps to reproduce

See example: https://github.com/tacoWanneeJama/BlazorAppGridFilter/settings

What is expected?

The webpage should off course be submitted from a Blazor page.

What is actually happening?

Page refresh

What browsers do you see the problem on?

Chrome

Any additional comments?

As workaround I now add an invisible text-field.

@tacoWanneeJama tacoWanneeJama added the Type: Bug 🐞 Something isn't working label Oct 21, 2024
@stsrki stsrki added this to the 1.6 support milestone Oct 22, 2024
@stsrki stsrki added this to Support Oct 22, 2024
@github-project-automation github-project-automation bot moved this to 🔙 Backlog in Support Oct 22, 2024
@tesar-tech tesar-tech self-assigned this Nov 4, 2024
@tesar-tech
Copy link
Collaborator

Your code:

<DataGrid TItem="Row" Filterable="true" Data="rows">
    <DataGridColumns>
        <DataGridNumericColumn Field="@nameof(Row.Id)" Displayable="false" />
        <DataGridColumn Field="@nameof(Row.Name)" />
    </DataGridColumns>

</DataGrid>

The issue can be extracted to:

<form>
    <input  type="text" />
</form>

here when you press Enter on the input it will always submit the form. That's standart html behavior.

The DataGrid is in form and with the filter input it does exactly that.

It's not intended behavior here.

We cannot effectively prevent that on the input itself (maybe with some weird js hack)

We can solve it by:

  • placing hidden textfield as @tacoWanneeJama suggested. It works, because with 2 inputs it just doesn't do the submit. Maybe the best solution.
  • Placing @onsubmit="() => {}" to the form. But that disables the submit altogether. With that we can replace it with <Div> .

That's my question for @stsrki - why is the DataGrid using Form? it seems it's not doing anything important.

@David-Moreira
Copy link
Contributor

Hey,

have you tried to set this parameter to false?
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Status: 🔙 Backlog
Development

No branches or pull requests

4 participants