File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 * Ensure that abnormally-shaped album art is still horizontally centered
66 * Add error handling on browser page for instances where the selected stream isn't browsable
77 * Add scrollbars to tall modals
8+ * Change how events are handled with Modals to reduce accidental closures
89* System
910 * Make update process properly report errors
1011
Original file line number Diff line number Diff line change 11import React from "react" ;
2-
32import "./Modal.scss" ;
43import StopProp from "@/components/StopProp/StopProp" ;
5-
64import PropTypes from "prop-types" ;
75
86const Modal = ( { children, className = "" , onClose } ) => {
7+ const [ mouseDownOutside , setMouseDownOutside ] = React . useState ( false ) ;
98 return (
109 < div
1110 className = { `modal_container ${ className } ` }
12- onClick = { ( e ) => {
13- onClose ( ) ;
14- e . stopPropagation ( ) ;
11+ onMouseDown = { ( e ) => {
12+ if ( e . target === e . currentTarget ) {
13+ setMouseDownOutside ( true ) ;
14+ } else {
15+ setMouseDownOutside ( false ) ;
16+ }
17+ } }
18+ onMouseUp = { ( e ) => {
19+ if ( mouseDownOutside && e . target === e . currentTarget ) {
20+ onClose ( ) ;
21+ }
1522 } }
1623 >
1724 < StopProp > { children } </ StopProp >
You can’t perform that action at this time.
0 commit comments