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

Bo ce filter list #22

Merged
merged 6 commits into from
Feb 21, 2024
Merged

Bo ce filter list #22

merged 6 commits into from
Feb 21, 2024

Conversation

borjaMarti
Copy link
Collaborator

Description

This PR adds a new component, SearchList.jsx, which can be used to filter the List view based on current input. The filtering is used to display only items which include the current input's value. The component also includes a button to clear the input field.

For this issue we had to deepen our understanding of React's component lifecycle and the way the useState hook updates its values. This came to be while having to update the list being displayed dynamically and its initial loading.

Related Issue

Closes #7

Acceptance Criteria

  • A form is added to the top of the List view, above the shopping list
  • The form includes the following elements
    • A text field (with semantic <label>!) which narrows down the list as the user types
    • When there’s text in the field, some kind of button (e.g., an X) to clear the field. When the field is cleared, the list is reset to its unfiltered state.

Type of Changes

Type
✨ New feature

Updates

Before

image

After

SmartShopping-SearchList

Testing Steps / QA Criteria

  1. git pull origin bo_ce_filter_list
  2. npm start
  3. Navigate to a list page
  4. Type on the input
  5. Check whether list is filtered according to the typed value
  6. Use 'X' button to clear input after typing. It should reset both the input and show the full list.

Copy link

github-actions bot commented Feb 19, 2024

Visit the preview URL for this PR (updated for commit 0aa76d9):

https://tcl-71-smart-shopping-list--pr22-bo-ce-filter-list-km16z2qf.web.app

(expires Tue, 27 Feb 2024 10:10:29 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 1e7ade9d0f374c4ddb5d7ab6fc541062fc7a1ab4

Copy link
Collaborator

@BikeMouse BikeMouse left a comment

Choose a reason for hiding this comment

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

Looking good!! Well done!!

const SearchList = ({ data, setNewList }) => {
const [value, setValue] = useState('');

const handlefiltering = (e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It can renamed with handleFiltering

const [value, setValue] = useState('');

const handlefiltering = (e) => {
const userinput = e.target.value.toLowerCase();
Copy link
Collaborator

@elitcenk elitcenk Feb 20, 2024

Choose a reason for hiding this comment

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

userInput

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Variable names updated!

Copy link
Collaborator

@vivitt vivitt left a comment

Choose a reason for hiding this comment

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

Nice job! The new feature works perfectly and meets all the requirements ✨

As a suggestion, I wonder if it wouldn't be clearer if the name of SearchList were something like SearchForm (given that it is a form similar to the ListForm we created in the previous issue with Celine).

Copy link
Collaborator

@elitcenk elitcenk 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 your effort.

@elitcenk elitcenk merged commit 3c73ee0 into main Feb 21, 2024
2 checks passed
@vivitt vivitt deleted the bo_ce_filter_list branch March 7, 2024 08:45
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.

7. As a user, I want to filter my shopping list to make it easier to locate an item in the list
5 participants