File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -109,17 +109,17 @@ export default class extends Controller {
109
109
this . previewTarget . style . display = 'none' ;
110
110
}
111
111
112
- onDragLeave ( event : any ) {
112
+ onDragLeave ( event : any ) {
113
113
event . preventDefault ( ) ;
114
-
114
+
115
115
// Check if we really leave the main drag area
116
116
if ( ! this . element . contains ( event . relatedTarget as Node ) ) {
117
117
this . inputTarget . style . display = 'none' ;
118
118
this . placeholderTarget . style . display = 'none' ;
119
119
this . previewTarget . style . display = 'block' ;
120
120
}
121
121
}
122
-
122
+
123
123
private dispatchEvent ( name : string , payload : any = { } ) {
124
124
this . dispatch ( name , { detail : payload , prefix : 'dropzone' } ) ;
125
125
}
Original file line number Diff line number Diff line change @@ -133,21 +133,21 @@ describe('DropzoneController', () => {
133
133
134
134
it ( 'on drag' , async ( ) => {
135
135
startStimulus ( ) ;
136
-
136
+
137
137
// Simulate dragenter event
138
138
const dragEnterEvent = new Event ( 'dragenter' ) ;
139
139
getByTestId ( container , 'container' ) . dispatchEvent ( dragEnterEvent ) ;
140
-
140
+
141
141
// Check that the input and placeholder are visible, and preview hidden
142
142
await waitFor ( ( ) => expect ( getByTestId ( container , 'input' ) ) . toHaveStyle ( { display : 'block' } ) ) ;
143
143
await waitFor ( ( ) => expect ( getByTestId ( container , 'placeholder' ) ) . toHaveStyle ( { display : 'block' } ) ) ;
144
144
await waitFor ( ( ) => expect ( getByTestId ( container , 'preview' ) ) . toHaveStyle ( { display : 'none' } ) ) ;
145
-
145
+
146
146
// Simulate dragleave event with relatedTarget set to outside the dropzone
147
147
const dragLeaveEvent = new Event ( 'dragleave' , { bubbles : true } ) ;
148
148
Object . defineProperty ( dragLeaveEvent , 'relatedTarget' , { value : document . body } ) ;
149
149
getByTestId ( container , 'container' ) . dispatchEvent ( dragLeaveEvent ) ;
150
-
150
+
151
151
// Check that the input and placeholder are hidden, and preview shown
152
152
await waitFor ( ( ) => expect ( getByTestId ( container , 'input' ) ) . toHaveStyle ( { display : 'none' } ) ) ;
153
153
await waitFor ( ( ) => expect ( getByTestId ( container , 'placeholder' ) ) . toHaveStyle ( { display : 'none' } ) ) ;
You can’t perform that action at this time.
0 commit comments