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

[BD-46] feat: escape press, backdrop click for Sheet #1217

Merged

Conversation

monteri
Copy link
Contributor

@monteri monteri commented Apr 6, 2022

Add processing of Escape press and backdrop click

  • on Escape sheet is closed. New requirement - pass new onClose prop that will be called on Escape.
  • on backdrop click. The same requirement as for Escape
  • along with this task also PAR-783 is completed. Backdrop click on the button that toggles Sheet has led to 2 actions at the same time - close on the backdrop event and open again on the button click. Changing <FocusOn enabled={this.props.blocking} /> to <FocusOn /> from react-focus-on always put focus inside the Sheet so that backdrop click can't trigger any event from outside of the Sheet.
  • added tests for new functionality

JIRA: PAR-784, PAR-783

@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program needs triage labels Apr 6, 2022
@openedx-webhooks
Copy link

Thanks for the pull request, @monteri! I've created BLENDED-1199 to keep track of it in Jira. More details are on the BD-46 project page.

When this pull request is ready, tag your edX technical lead.

@netlify
Copy link

netlify bot commented Apr 6, 2022

Deploy Preview for paragon-openedx ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit edc24a4
🔍 Latest deploy log https://app.netlify.com/sites/paragon-openedx/deploys/62504f88ad807b0008819e90
😎 Deploy Preview https://deploy-preview-1217--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 settings.

@monteri monteri changed the title [BD-46] feat: Escape, backdrop click [BD-46] feat: escape press, backdrop click for Sheet Apr 6, 2022
@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #1217 (edc24a4) into master (ece44ed) will increase coverage by 0.06%.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master    #1217      +/-   ##
==========================================
+ Coverage   90.77%   90.84%   +0.06%     
==========================================
  Files         193      193              
  Lines        3069     3101      +32     
  Branches      691      699       +8     
==========================================
+ Hits         2786     2817      +31     
- Misses        270      271       +1     
  Partials       13       13              
Impacted Files Coverage Δ
src/Sheet/index.jsx 94.73% <75.00%> (-5.27%) ⬇️
src/Dropdown/index.jsx 97.22% <0.00%> (-2.78%) ⬇️
src/DataTable/index.jsx 94.82% <0.00%> (ø)
src/utils/propTypesUtils.js 90.90% <0.00%> (+9.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ece44ed...edc24a4. Read the comment docs.

Comment on lines 30 to 50
componentDidMount() {
document.addEventListener('keydown', this.handleEscape);
document.addEventListener('mousedown', this.handleClickOutside);
}

componentWillUnmount() {
document.removeEventListener('keydown', this.handleEscape);
document.removeEventListener('mousedown', this.handleClickOutside);
}

handleEscape(e) {
if (e.key === 'Escape' && !this.props.blocking) {
this.props.onClose();
}
}

handleClickOutside(e) {
if (this.wrapperRef?.current && !this.wrapperRef.current.contains(e.target) && !this.props.blocking) {
this.props.onClose();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

[curious] I wonder if we could use the callback functions from FocusOn here to simplify this?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is super good idea. Works perfect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the only thing, I didn't manage how to test these new events, so I removed new tests

@adamstankiewicz adamstankiewicz merged commit b46b094 into openedx:master Apr 22, 2022
@openedx-webhooks
Copy link

@monteri 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 19.18.4 🎉

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
Labels
blended PR is managed through 2U's blended developmnt program merged released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants