Skip to content

Conversation

anoopadvaitha
Copy link
Contributor

Currently DataSearch filters data as soon as we start typing (onchange). This becomes challenge in scenarios where the data is fetched from API.

What does this PR do?

The PR provides updateOn parameter which is passed to DataForm so that developer can leverage to either use change or submit.

Where should the reviewer start?

\src\js\components\DataSearch\DataSearch.js

What testing has been done on this PR?

Tested when no value is provided for DataSearch and when submit is provided and works in both scenarios.

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

#7024

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Yes, will be raising the PR on that

Should this PR be mentioned in the release notes?

No.

Is this change backwards compatible or is it a breaking change?

Yes

@jcfilben jcfilben added PRty Biweekly PR reviews by grommet team with hoping of closing such PRs Data and friends For data components in grommet labels Nov 28, 2023
@jcfilben jcfilben mentioned this pull request Nov 28, 2023
3 tasks
@taysea taysea added the discussion Needs deeper discussions label Nov 29, 2023
</Grommet>,
);

expect(container.firstChild).toMatchSnapshot();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the snapshot test isn't really capturing the behavior we actually want to test here. If we could write the test so that it tests typing something into search and then pressing the enter key I think that would be ideal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the test case and it is failing, even after providing a filter value and doing submit/ simulating enter. The snapshot still has other values.
But it is working as expected in storybook.
Can you please help me on this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried userEvent which is timing out.

@MikeKingdom
Copy link
Collaborator

Just an update on this PR: I think the updateOn="submit" is great and I did a few minor tweaks while looking at how to get the jest test to actually submit the search when enter is pressed. But as we've been looking at a few other issues in the Data* components and how they use a Form we decided we want to remove the use of Form for most of these. So my next steps here are to refactor DataSearch to not use form, and I'll make sure the updateOn="submit" is still implemented so you can trigger the search via the enter key rather than while typing each character.

@anoopadvaitha
Copy link
Contributor Author

Just an update on this PR: I think the updateOn="submit" is great and I did a few minor tweaks while looking at how to get the jest test to actually submit the search when enter is pressed. But as we've been looking at a few other issues in the Data* components and how they use a Form we decided we want to remove the use of Form for most of these. So my next steps here are to refactor DataSearch to not use form, and I'll make sure the updateOn="submit" is still implemented so you can trigger the search via the enter key rather than while typing each character.

That sounds like a plan!
Thank you!

Copy link
Collaborator

@MikeKingdom MikeKingdom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anoopadvaitha With the changes to remove Form from DataSearch I created an newer implementation of this feature in #7110

@MikeKingdom
Copy link
Collaborator

Superseded by #7110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data and friends For data components in grommet discussion Needs deeper discussions PRty Biweekly PR reviews by grommet team with hoping of closing such PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants