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

fix: add isActive to FormAutosuggest state #2517

Conversation

cintnguyen
Copy link
Contributor

@cintnguyen cintnguyen commented Aug 9, 2023

Description

state.dropDownItems.length > 0 used to determine if an autosuggest component was active or not which was inaccurate. Found an alternative way to specify which component is being interacted with through setting a new bool isActive on the state.

Resolves : #2510

Deploy Preview

https://deploy-preview-2517--paragon-openedx.netlify.app/components/form/form-autosuggest/

Merge Checklist

  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please add wittjeff and adamstankiewicz as reviewers on this PR.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@netlify
Copy link

netlify bot commented Aug 9, 2023

Deploy Preview for paragon-openedx ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 31df4cc
🔍 Latest deploy log https://app.netlify.com/sites/paragon-openedx/deploys/64f78098c8af0400089f8b0e
😎 Deploy Preview https://deploy-preview-2517--paragon-openedx.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Patch coverage: 88.88% and project coverage change: +0.01% 🎉

Comparison is base (93bf239) 91.70% compared to head (31df4cc) 91.72%.
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2517      +/-   ##
==========================================
+ Coverage   91.70%   91.72%   +0.01%     
==========================================
  Files         236      235       -1     
  Lines        4219     4217       -2     
  Branches     1021     1020       -1     
==========================================
- Hits         3869     3868       -1     
+ Misses        346      345       -1     
  Partials        4        4              
Files Changed Coverage Δ
src/Form/FormAutosuggest.jsx 95.69% <88.88%> (+1.25%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brian-smith-tcril
Copy link
Contributor

@adamstankiewicz just a heads up on this one that the only failing part is codecov (and the overall coverage is actually higher than it was before this PR)

e.preventDefault();

setState(prevState => ({
...prevState,
dropDownItems: [],
errorMessage: !state.displayValue ? errorMessageText : '',
Copy link
Member

Choose a reason for hiding this comment

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

[clarification] If removing the errorMessage state here and below, is it correct that this component will no longer be using the errorMessageText prop anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not changing the errorMessage state in the keyDownHandler since the user will still be focused on the component even when they type esc (because this only closes the drop down) #2516. Therefore, we wouldn't want there to be any reported errors until they have left the component.

We still are keeping errorMessageText prop since we use it in handleDocumentClick function above.

@adamstankiewicz
Copy link
Member

@cintnguyen LGTM. Looks like there's just a conflict in the FormAutosuggest component that will need to be addressed now.

state.dropDownItems.length > 0 used to determine if an autosuggest component was active or not which was inaccurate. Found an alternative way to specify which component is being interacted with through setting a new bool isActive on the state.
@cintnguyen cintnguyen force-pushed the cindy/formAutosuggest-add-isActive-to-state branch from 94d97dc to 31df4cc Compare September 5, 2023 19:25
@cintnguyen
Copy link
Contributor Author

@adamstankiewicz Merge conflict resolved!

@brian-smith-tcril brian-smith-tcril merged commit 4816baa into openedx:master Sep 11, 2023
8 of 9 checks passed
@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 21.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 22.0.0-alpha.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autosuggest: use something other than state.dropDownItems.length > 0 to filter document clicks
4 participants