@@ -122,12 +122,19 @@ export class ChatWidget extends ReactWidget {
122
122
* Handle drag over events
123
123
*/
124
124
private _handleDrag ( event : Drag . Event ) : void {
125
- const inputContainer = this . node . querySelector ( `.${ INPUT_CONTAINER_CLASS } ` ) ;
125
+ const inputContainers = this . node . querySelectorAll < HTMLElement > (
126
+ `.${ INPUT_CONTAINER_CLASS } `
127
+ ) ;
126
128
const target = event . target as HTMLElement ;
127
- const isOverInput =
128
- inputContainer ?. contains ( target ) || inputContainer === target ;
129
+ let overInput : HTMLElement | null = null ;
130
+ for ( const container of inputContainers ) {
131
+ if ( container . contains ( target ) ) {
132
+ overInput = container ;
133
+ break ;
134
+ }
135
+ }
129
136
130
- if ( ! isOverInput ) {
137
+ if ( ! overInput ) {
131
138
this . _removeDragHoverClass ( ) ;
132
139
return ;
133
140
}
@@ -140,12 +147,9 @@ export class ChatWidget extends ReactWidget {
140
147
event . stopPropagation ( ) ;
141
148
event . dropAction = 'move' ;
142
149
143
- if (
144
- inputContainer &&
145
- ! inputContainer . classList . contains ( DRAG_HOVER_CLASS )
146
- ) {
147
- inputContainer . classList . add ( DRAG_HOVER_CLASS ) ;
148
- this . _dragTarget = inputContainer as HTMLElement ;
150
+ if ( ! overInput . classList . contains ( DRAG_HOVER_CLASS ) ) {
151
+ overInput . classList . add ( DRAG_HOVER_CLASS ) ;
152
+ this . _dragTarget = overInput ;
149
153
}
150
154
}
151
155
@@ -184,8 +188,15 @@ export class ChatWidget extends ReactWidget {
184
188
}
185
189
}
186
190
187
- private _getActiveInput ( ) : IInputModel {
188
- return this . model . input . currentEdition ?? this . model . input ;
191
+ private _getTargetInput ( event : Drag . Event ) : IInputModel {
192
+ const target = event . target as HTMLElement ;
193
+
194
+ for ( const edition of this . model . input . activeEditions ?? [ ] ) {
195
+ if ( edition . node && edition . node . contains ( target ) ) {
196
+ return edition ;
197
+ }
198
+ }
199
+ return this . model . input ;
189
200
}
190
201
191
202
/**
@@ -206,7 +217,7 @@ export class ChatWidget extends ReactWidget {
206
217
value : data . model . path ,
207
218
mimetype : data . model . mimetype
208
219
} ;
209
- const activeInput = this . _getActiveInput ( ) ;
220
+ const activeInput = this . _getTargetInput ( event ) ;
210
221
activeInput . addAttachment ?.( attachment ) ;
211
222
}
212
223
@@ -269,7 +280,7 @@ export class ChatWidget extends ReactWidget {
269
280
value : notebookPath ,
270
281
cells : validCells
271
282
} ;
272
- const activeInput = this . _getActiveInput ( ) ;
283
+ const activeInput = this . _getTargetInput ( event ) ;
273
284
activeInput . addAttachment ?.( attachment ) ;
274
285
}
275
286
} catch ( error ) {
0 commit comments