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

Adding Modal component #18156

Closed
wants to merge 3 commits into from
Closed

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented Mar 14, 2023

Explanation

Adding Modal component based on insight report. This PR adds the final components to complete the new Modal component as well as stories, documentation and tests. It also introduces a ModalFocus component that uses the react-focus-lock library to improve the accessibility of our Modal component for keyboard only users.

Screenshots/Screencaps

After

after.mov

Text coverage for Modal and ModalFocus

Screenshot 2023-04-27 at 11 56 09 AM

Manual Testing Steps

  • Go to the latest storybook build on this PR
  • Search Modal in the search bar
  • View stories, controls and docs

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@georgewrmarshall georgewrmarshall added the team-design-system All issues relating to design system in Extension label Mar 14, 2023
@georgewrmarshall georgewrmarshall self-assigned this Mar 14, 2023
@georgewrmarshall georgewrmarshall added the DO-NOT-MERGE Pull requests that should not be merged label Mar 14, 2023
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Collaborator

Builds ready [5d6cf3e]
Page Load Metrics (1637 ± 43 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint98149115147
domContentLoaded1491174816007436
load1512183816378943
domInteractive1491174816007436
Bundle size diffs
  • background: 0 bytes
  • ui: 9087 bytes
  • common: 0 bytes

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #18156 (284bce6) into develop (7a421e0) will decrease coverage by 0.07%.
The diff coverage is 32.93%.

❗ Current head 284bce6 differs from pull request most recent head b3ab924. Consider uploading reports for the commit b3ab924 to get more accurate results

@@             Coverage Diff             @@
##           develop   #18156      +/-   ##
===========================================
- Coverage    64.11%   64.04%   -0.07%     
===========================================
  Files          910      916       +6     
  Lines        35516    35604      +88     
  Branches      9008     9031      +23     
===========================================
+ Hits         22768    22800      +32     
- Misses       12748    12804      +56     
Impacted Files Coverage Δ
...nt-library/modal-content/modal-content.stories.tsx 0.00% <0.00%> (ø)
...nt-library/modal-overlay/modal-overlay.stories.tsx 0.00% <0.00%> (ø)
...mponents/component-library/modal/modal.stories.tsx 0.00% <0.00%> (ø)
ui/components/component-library/modal/modal.tsx 57.14% <57.14%> (ø)
.../component-library/modal-content/modal-content.tsx 100.00% <100.00%> (ø)
.../component-library/modal-overlay/modal-overlay.tsx 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from 5d6cf3e to 284bce6 Compare March 15, 2023 03:41
@metamaskbot
Copy link
Collaborator

Builds ready [284bce6]
Page Load Metrics (1567 ± 70 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint89147113168
domContentLoaded13681817153512661
load13681914156714570
domInteractive13681817153512661
Bundle size diffs
  • background: 0 bytes
  • ui: 9087 bytes
  • common: 0 bytes

@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from 284bce6 to b3ab924 Compare March 15, 2023 19:32
@eriknson
Copy link
Member

What's the status / ETA on this modal component?

@georgewrmarshall
Copy link
Contributor Author

georgewrmarshall commented Mar 16, 2023

@eriknson hoping to get this into a reviewable state soon. Rough eta 2 weeks

@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from b3ab924 to 7cc9685 Compare March 17, 2023 19:01
@georgewrmarshall georgewrmarshall changed the title Adding Modal, ModalOverlay, ModalContent components (WIP) Adding Modal component Apr 4, 2023
@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from 7cc9685 to bb6f0b9 Compare April 25, 2023 03:12
@georgewrmarshall georgewrmarshall changed the title Adding Modal component Adding Modal component (WIP) Apr 25, 2023
@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from bb6f0b9 to 752a27d Compare April 25, 2023 11:20
@socket-security
Copy link

socket-security bot commented Apr 25, 2023

New dependency changes detected. Learn more about Socket for GitHub ↗︎


🚨 Potential security issues found in this pull request. To accept the risk, merge this PR and you will not be notified again.

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] bar@* or ignore all packages with @SocketSecurity ignore-all

⚠️ URL strings

Package contains fragments of external URLs or IP addresses, which may indicate that it covertly exfiltrates data.

Avoid using packages that make connections to the network, since this helps to leak data.

Package URL Fragment Location Source
[email protected] (added) https://github.com/theKashey/focus-lock/#focus-fighting dist/es2015/setFocus.js package.json via [email protected]
[email protected] (added) https://github.com/theKashey/focus-lock/#focus-fighting dist/es2019/setFocus.js package.json via [email protected]
[email protected] (added) https://github.com/theKashey/focus-lock/#focus-fighting dist/es5/setFocus.js package.json via [email protected]
⚠️ Environment variable access

Package accesses environment variables, which may be a sign of credential stuffing or data theft.

Packages should be clear about which environment variables they access, and care should be taken to ensure they only access environment variables they claim to.

Package ENV Vars Location Source
[email protected] (added) lib/index.es.js package.json via [email protected]
[email protected] (added) lib/index.es.js package.json via [email protected]
[email protected] (added) lib/index.es.js package.json via [email protected]
[email protected] (added) lib/index.es.js package.json via [email protected]
[email protected] (added) lib/index.js package.json via [email protected]
[email protected] (added) lib/index.js package.json via [email protected]
[email protected] (added) lib/index.js package.json via [email protected]
[email protected] (added) lib/index.js package.json via [email protected]
[email protected] (added) lib/index.umd.js package.json via [email protected]
[email protected] (added) lib/index.umd.js package.json via [email protected]
[email protected] (added) lib/index.umd.js package.json via [email protected]
[email protected] (added) lib/index.umd.js package.json via [email protected]
[email protected] (added) lib/index.umd.min.js package.json via [email protected]
[email protected] (added) lib/index.umd.min.js package.json via [email protected]
[email protected] (added) lib/index.umd.min.js package.json via [email protected]
[email protected] (added) lib/index.umd.min.js package.json via [email protected]
[email protected] (added) dist/cjs/AutoFocusInside.js package.json
[email protected] (added) dist/cjs/AutoFocusInside.js package.json
[email protected] (added) dist/cjs/clientSideEffect.js package.json
[email protected] (added) dist/cjs/clientSideEffect.js package.json
[email protected] (added) dist/cjs/clientSideEffect.js package.json
[email protected] (added) dist/cjs/clientSideEffect.js package.json
[email protected] (added) dist/cjs/Combination.js package.json
[email protected] (added) dist/cjs/Combination.js package.json
[email protected] (added) dist/cjs/FocusGuard.js package.json
[email protected] (added) dist/cjs/FocusGuard.js package.json
[email protected] (added) dist/cjs/FreeFocusInside.js package.json
[email protected] (added) dist/cjs/FreeFocusInside.js package.json
[email protected] (added) dist/cjs/Lock.js package.json
[email protected] (added) dist/cjs/Lock.js package.json
[email protected] (added) dist/cjs/Lock.js package.json
[email protected] (added) dist/cjs/Lock.js package.json
[email protected] (added) dist/cjs/MoveFocusInside.js package.json
[email protected] (added) dist/cjs/MoveFocusInside.js package.json
[email protected] (added) dist/cjs/Trap.js package.json
[email protected] (added) dist/cjs/Trap.js package.json
[email protected] (added) dist/es2015/AutoFocusInside.js package.json
[email protected] (added) dist/es2015/AutoFocusInside.js package.json
[email protected] (added) dist/es2015/clientSideEffect.js package.json
[email protected] (added) dist/es2015/clientSideEffect.js package.json
[email protected] (added) dist/es2015/clientSideEffect.js package.json
[email protected] (added) dist/es2015/clientSideEffect.js package.json
[email protected] (added) dist/es2015/Combination.js package.json
[email protected] (added) dist/es2015/Combination.js package.json
[email protected] (added) dist/es2015/FocusGuard.js package.json
[email protected] (added) dist/es2015/FocusGuard.js package.json
[email protected] (added) dist/es2015/FreeFocusInside.js package.json
[email protected] (added) dist/es2015/FreeFocusInside.js package.json
[email protected] (added) dist/es2015/Lock.js package.json
[email protected] (added) dist/es2015/Lock.js package.json
[email protected] (added) dist/es2015/Lock.js package.json
[email protected] (added) dist/es2015/Lock.js package.json
[email protected] (added) dist/es2015/MoveFocusInside.js package.json
[email protected] (added) dist/es2015/MoveFocusInside.js package.json
[email protected] (added) dist/es2015/Trap.js package.json
[email protected] (added) dist/es2015/Trap.js package.json
⚠️ No tests

Package does not have any tests. This is a strong signal of a poorly maintained or low quality package.

Add tests and publish a new version of the package. Consumers may look for an alternative package with better testing.

Package Location Source
[email protected] (added) package.json package.json via [email protected]
⚠️ No v1

Package is not semver >=1. This means it is not stable and does not support ^ ranges.

If the package sees any general use, it should begin releasing at version 1.0.0 or later to benefit from semver.

Package Location Source
[email protected] (added) Package overview package.json via [email protected]
⚠️ Unmaintained

Package has not been updated in more than a year and may be unmaintained. Problems with the package may go unaddressed.

Package should publish periodic maintenance releases if they are maintained, or deprecate if they have no intention in further maintenance.

Package Last Publish Date Source
[email protected] (added) 4/18/2022, 2:22:06 AM package.json via [email protected]
[email protected] (added) 4/18/2022, 6:41:26 AM package.json via [email protected]
[email protected] (added) 3/18/2021, 12:59:32 AM package.json via [email protected]
Pull request alert summary
Issue Status
Critical CVE ✅ 0 issues
CVE ✅ 0 issues
Mild CVE ✅ 0 issues
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script confusion ✅ 0 issues
Bin script shell injection ✅ 0 issues
Filesystem access ✅ 0 issues
Network access ✅ 0 issues
Shell access ✅ 0 issues
Debug access ✅ 0 issues
Long strings ✅ 0 issues
High entropy strings ✅ 0 issues
URL strings ⚠️ 3 issues
Uses eval ✅ 0 issues
Dynamic require ✅ 0 issues
Environment variable access ⚠️ 56 issues
Missing dependency ✅ 0 issues
Unused dependency ✅ 0 issues
Peer dependency ✅ 0 issues
Uncaught optional dependency ✅ 0 issues
Unresolved require ✅ 0 issues
Extraneous dependency ✅ 0 issues
Obfuscated require ✅ 0 issues
Obfuscated code ✅ 0 issues
Minified code ✅ 0 issues
Bidirectional unicode control characters ✅ 0 issues
Zero width unicode chars ✅ 0 issues
Bad text encoding ✅ 0 issues
Unicode homoglyphs ✅ 0 issues
Invisible chars ✅ 0 issues
Suspicious strings ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
GitHub dependency ✅ 0 issues
File dependency ✅ 0 issues
No tests ⚠️ 1 issue
No repository ✅ 0 issues
Bad semver ✅ 0 issues
Bad dependency semver ✅ 0 issues
No v1 ⚠️ 1 issue
No website ✅ 0 issues
No bug tracker ✅ 0 issues
No contributors or author data ✅ 0 issues
CommonJS depending on ESModule ✅ 0 issues
Empty package ✅ 0 issues
Trivial Package ✅ 0 issues
No README ✅ 0 issues
Deprecated ✅ 0 issues
Chronological version anomaly ✅ 0 issues
Semver anomaly ✅ 0 issues
New author ✅ 0 issues
Unstable ownership ✅ 0 issues
Non-existent author ✅ 0 issues
Unmaintained ⚠️ 3 issues
Unpublished package ✅ 0 issues
Major refactor ✅ 0 issues
Missing package tarball ✅ 0 issues
Unsafe copyright ✅ 0 issues
License change ✅ 0 issues
Non OSI license ✅ 0 issues
Deprecated license ✅ 0 issues
Missing license ✅ 0 issues
Non SPDX license ✅ 0 issues
Unclear license ✅ 0 issues
Mixed license ✅ 0 issues
Legal notice ✅ 0 issues
Modified license ✅ 0 issues
Modified license exception ✅ 0 issues
License exception ✅ 0 issues
Deprecated SPDX exception ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
AI detected security risk ✅ 0 issues
AI warning ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
[email protected] environment +5 kashey

@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from 752a27d to bb3d17b Compare April 26, 2023 12:51
@georgewrmarshall georgewrmarshall removed the DO-NOT-MERGE Pull requests that should not be merged label Apr 26, 2023
@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch 2 times, most recently from 232972c to 98cffd6 Compare April 27, 2023 02:33
@georgewrmarshall georgewrmarshall marked this pull request as ready for review April 27, 2023 02:34
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner April 27, 2023 02:34
@georgewrmarshall georgewrmarshall changed the title Adding Modal component (WIP) Adding Modal component Apr 27, 2023
@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from 98cffd6 to 174ee0d Compare April 27, 2023 02:50
@@ -333,6 +333,7 @@
"qrcode.react": "^1.0.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-focus-lock": "^2.9.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using react-focus-lock library to lock focus to the ModalContent component or to whatever component uses the modalContentRef ref to improve the accessibility for keyboard only and screen reader users

@@ -25,6 +25,9 @@ export const ModalContent = ({
{ [`mm-modal-content--size-${size}`]: !width },
className,
)}
as="section"
role="dialog"
aria-modal="true"
backgroundColor={BackgroundColor.backgroundDefault}
borderRadius={BorderRadius.LG}
width={width || BLOCK_SIZES.FULL}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

screenreader and semantic html improvements copied from Chakra UI

@@ -21,6 +21,7 @@ export const ModalOverlay: React.FC<ModalOverlayProps> = ({
width={BLOCK_SIZES.FULL}
height={BLOCK_SIZES.FULL}
onClick={onClick}
aria-hidden="true"
{...props}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

screenreader improvements copied from Chakra UI


# Modal

The `Modal` focuses the user's attention exclusively on information via a window that is overlaid on primary content. It uses `ModalOverlay`, `ModalContent` and `ModalHeader` to create a modal dialog.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to

Suggested change
The `Modal` focuses the user's attention exclusively on information via a window that is overlaid on primary content. It uses `ModalOverlay`, `ModalContent` and `ModalHeader` to create a modal dialog.
The `Modal` focuses the user's attention exclusively on information via a window that is overlaid on primary content. It should be used with the `ModalOverlay`, `ModalContent` and `ModalHeader` components to create a complete modal.

@georgewrmarshall georgewrmarshall requested review from darkwing and removed request for hmalik88 April 27, 2023 03:11
@metamaskbot
Copy link
Collaborator

Builds ready [9cbf2c3]
Page Load Metrics (1506 ± 32 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint96133106105
domContentLoaded1401161714945828
load1404165915066732
domInteractive1401161714945828
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1023 bytes
  • ui: 74998 bytes
  • common: 0 bytes

@darkwing
Copy link
Contributor

Should we add a story with large amounts of content so we see how scrolling looks in the modal?

@georgewrmarshall georgewrmarshall requested a review from a team as a code owner April 28, 2023 00:01
@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from 6278584 to cc9383e Compare April 28, 2023 00:16
@georgewrmarshall georgewrmarshall force-pushed the feat/15432/modal-component branch from cc9383e to fcd858e Compare April 28, 2023 00:17
@georgewrmarshall
Copy link
Contributor Author

Should we add a story with large amounts of content so we see how scrolling looks in the modal?

Great point! I think you have identified a BIG BUG with this Modal implementation thank you!!

@metamaskbot
Copy link
Collaborator

Builds ready [fcd858e]
Page Load Metrics (1605 ± 42 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint97172123178
domContentLoaded1364170315957938
load1364177816058842
domInteractive1364170315957938
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1023 bytes
  • ui: 74998 bytes
  • common: 0 bytes

@georgewrmarshall georgewrmarshall marked this pull request as draft April 28, 2023 01:20
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team-design-system All issues relating to design system in Extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Ext] Create component: Modal
5 participants