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

[MI-400] Advanced Search with multi table view #535

Merged
merged 5 commits into from
Sep 3, 2024

Conversation

vmangwani
Copy link
Contributor

@vmangwani vmangwani commented Aug 29, 2024

JIRA

MI-400

Description

Our team is working on revamping the search experience and as a part the first step is to update the dropdown, here's the figma for the new dropdown view,
https://www.figma.com/design/XpIvfVpAYzgej225MXdcgL/Dashboard-v2?node-id=5198-903&t=DG2IJyhTMvrRKwdY-0

This component builds a multi table dropdown that can populate data from Campaigns, Orders, Templates etc

Screenshot 2024-08-29 at 2 03 59 PM

@vmangwani vmangwani marked this pull request as ready for review August 29, 2024 23:43
@vmangwani vmangwani requested a review from a team as a code owner August 29, 2024 23:43
Copy link
Contributor

@NateWaldschmidt NateWaldschmidt left a comment

Choose a reason for hiding this comment

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

This is looking great, awesome work! I know I left a good number of comments and am happy to hop in a call to work through them together if that helps 😄

package.json Outdated Show resolved Hide resolved
src/components/AdvancedSearchBar/AdvancedSearchBar.vue Outdated Show resolved Hide resolved
src/components/AdvancedSearchBar/AdvancedSearchBar.vue Outdated Show resolved Hide resolved
src/components/AdvancedSearchBar/AdvancedSearchBar.vue Outdated Show resolved Hide resolved
Comment on lines 125 to 132
props
.searchFunction(searchTerm)
.then((results) => {
searchResults.value = results;
})
.finally(() => {
searching.value = false;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

async/ await is easier to read and generally preferred when possible

Suggested change
props
.searchFunction(searchTerm)
.then((results) => {
searchResults.value = results;
})
.finally(() => {
searching.value = false;
});
searching.value = true; // Not sure if this is needed, I don't see where it gets set to `true`
searchResults.value = await props.searchFunction(searchTerm.value);
searching.value = false;

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 don't think the searching.value is needed as the caller is setting it already. Because these are components we don't want to use await as that could have unintended consequences. Hence using a .then() which resolves after the result is available.

Copy link
Contributor

@NateWaldschmidt NateWaldschmidt Aug 30, 2024

Choose a reason for hiding this comment

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

Would we be able to move the searching.value = false be next to the place that is being set to true? Otherwise its hard to know if that is being triggered

What are the unintended consequences of using await in components? I have used async functions within many components without issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I just looked at it and because the searchFunction is being called in a setTimeout method it's ok to add await. But generally component libraries functions being async is a little different, because then the consumer would need to know its async which 90% of our components are not.

src/components/AdvancedSearchBar/AdvancedSearchBar.vue Outdated Show resolved Hide resolved
src/components/AdvancedSearchBar/AdvancedSearchBar.vue Outdated Show resolved Hide resolved
Comment on lines +174 to +180
onMounted(() => {
window.addEventListener('click', onClickOutside);
});

onUnmounted(() => {
window.removeEventListener('click', onClickOutside);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like the Vue way of doing things as its using plain JS event handlers. This could justify a new Vue hook with reactive state attached to it. This also seems like there is a concern for accessibility since people who don't utilize a mouse can't click outside (I would think focus would control this)

Feel free to ignore this one as it may be a decent lift to do some of this but wanted note it

Copy link
Contributor

@NateWaldschmidt NateWaldschmidt left a comment

Choose a reason for hiding this comment

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

Looks great! 🔥

@vmangwani vmangwani merged commit 1647f0e into main Sep 3, 2024
4 of 5 checks passed
@vmangwani vmangwani deleted the feature/MI-400_Create_new_search_component branch September 3, 2024 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants