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

added event keydown to prevent < or > #433

Merged
merged 24 commits into from
Sep 21, 2022

Conversation

wannieman98
Copy link
Contributor

@wannieman98 wannieman98 commented Apr 16, 2022

For the search input in the search box module, I added a keydown event to replace special characters '<' and '>' whenever a user typed that into the search input box.

Pull request template

This PR is meant to improve and add a feature to an existing search input module. In detail, a function has been added that will check if the input query contains a '<' or a '>' and if it exists replace it with ''. This PR fixes #383.

Motivation and context

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to not work as expected)
  • Change requires a documentation update

What is the destination branch of this PR?

  • Main
  • Other. Specify:

How has this been tested?

Tests performed according to testing guidelines: In order to test the feature that I implemented work, I gave mock search input several varying string values that has special characters '<' and '>' around the string "water". Using a for loop, checked whether the search feature properly eliminated the special characters and return the string "water". This code should not affect other areas of code.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review on my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@herrardo herrardo requested review from a team and removed request for a team April 16, 2022 19:46
@wannieman98 wannieman98 marked this pull request as ready for review April 18, 2022 06:17
@wannieman98 wannieman98 requested a review from a team as a code owner April 18, 2022 06:17
Copy link
Contributor

@javieri-empathy javieri-empathy left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, we really appreciate it! 😄

package-lock.json Outdated Show resolved Hide resolved
.parcel-cache/7dc7401b7c586711.txt Outdated Show resolved Hide resolved
packages/tailwindcss-x/src/main.d.ts Outdated Show resolved Hide resolved
@wannieman98
Copy link
Contributor Author

Hey @javieri-empathy! I have currently added the cypress add to test the typing of the special characters. For the pasting and using url with search query, I have kept the keydown method to remove the special characters as it prevents the user from further typing or pressing enter. If I keep this functionality, then we will be able to test this behavior with jest. I believe this solves both cases. If there is a problem please let me know!

@diegopf
Copy link
Contributor

diegopf commented Jun 8, 2022

Hey @javieri-empathy! I have currently added the cypress add to test the typing of the special characters. For the pasting and using url with search query, I have kept the keydown method to remove the special characters as it prevents the user from further typing or pressing enter. If I keep this functionality, then we will be able to test this behavior with jest. I believe this solves both cases. If there is a problem please let me know!

@wannieman98 I've took a look and I think you can just rely on beforeinput event and remove preventPastingSpecialKey. The preventTypingSpecialKey should be enough to achieve the goal here. Besides, we should also remove the jest tests and only keep the cypress one.

Please, don't forget to rollback the parcel-cache files 🙂

Copy link
Contributor

@diegopf diegopf left a comment

Choose a reason for hiding this comment

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

Good job, thanks for the contribution! ;)

@wannieman98
Copy link
Contributor Author

Hey @javieri-empathy! I have currently added the cypress add to test the typing of the special characters. For the pasting and using url with search query, I have kept the keydown method to remove the special characters as it prevents the user from further typing or pressing enter. If I keep this functionality, then we will be able to test this behavior with jest. I believe this solves both cases. If there is a problem please let me know!

@wannieman98 I've took a look and I think you can just rely on beforeinput event and remove preventPastingSpecialKey. The preventTypingSpecialKey should be enough to achieve the goal here. Besides, we should also remove the jest tests and only keep the cypress one.

Please, don't forget to rollback the parcel-cache files 🙂

Hi @diegopf, thanks for the review! I have made the requested changes as well as rolling back the parcel-caches as well as the removing the jest tests. I have ran merged with the main branch in the repo and ran the tests! If there is any problem please let me know, I'd appreciate it.

@wannieman98 wannieman98 requested a review from diegopf June 9, 2022 08:34
javieri-empathy
javieri-empathy previously approved these changes Jun 9, 2022
diegopf
diegopf previously approved these changes Sep 20, 2022
@mnavarroespinosa mnavarroespinosa merged commit afc865f into empathyco:main Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Avoid forbidden characters in the search box
5 participants