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

refactor: Migrate preselected filters component #1422

Merged

Conversation

annacv
Copy link
Contributor

@annacv annacv commented Feb 21, 2024

Pull request template

Migrate the PreselectedFilters component to Vue 2.7

Motivation and context

  • Dependencies. If any, specify:
  • Open issue. If applicable, link: EMP-3378

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:

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.

TEST
Check the component is working as expected:

  • Use this code snippet before initialising the library:
InterfaceX.setSnippetConfig({
  filters: [`brand:marni`]
});
  • When X is opened, search for a query and check that the filter is shown as selected.
  • Close X, do the same again with another filter & check that the new search applies the new filter.
  • Additionally you can use the PreselectedFilters component and pass a filter using the filters prop.

@annacv annacv requested a review from a team as a code owner February 21, 2024 11:39
@annacv annacv requested a review from CachedaCodes March 4, 2024 15:48
Comment on lines 34 to 39
const eventMetadata = {
moduleName: null,
location: 'none',
replaceable: true
};

Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't care what the metadata is in the tests, you can use expect.any(Object).
Remove this and use that instead.

Comment on lines 78 to 79
return () => useNoElementRender(slots);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the render function instead, it's more declarative.

Suggested change
return () => useNoElementRender(slots);
}
},
render() {
return useNoElementRender(this.$slots)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, if I'm not wrong render is only available if we use the Options API, for the Composition API we should use h and return it directly, which I think is almost the same we are doing now.

Copy link
Contributor

Choose a reason for hiding this comment

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

The defineComponent function receives an options object that is more or less the same type of object you create in the options API (you are using it already, passing the props and setting up a name). render is one of the options that you can send to defineComponent and will work with setup when setup doesn't use return

@annacv annacv requested a review from CachedaCodes March 5, 2024 10:06
Comment on lines 78 to 79
return () => useNoElementRender(slots);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The defineComponent function receives an options object that is more or less the same type of object you create in the options API (you are using it already, passing the props and setting up a name). render is one of the options that you can send to defineComponent and will work with setup when setup doesn't use return

@annacv annacv requested a review from CachedaCodes March 6, 2024 15:45
@CachedaCodes CachedaCodes merged commit 4a38318 into main Mar 13, 2024
4 checks passed
@CachedaCodes CachedaCodes deleted the feature/EMP-3378-Migrate-preselected-filters-component branch March 13, 2024 08:37
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.

2 participants