Skip to content

Commit

Permalink
#2244 - Drag and Drop file upload doesn't work in Safari (#2253)
Browse files Browse the repository at this point in the history
* remove the items check

* flaky test
  • Loading branch information
SebinSong committed Jul 25, 2024
1 parent cb73265 commit dd39cca
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions frontend/views/containers/chatroom/ChatMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.c-chat-main(
v-if='summary.chatRoomID'
:class='{ "is-dnd-active": dndState && dndState.isActive }'
@dragstart='dragStartHandler'
@dragover='dragStartHandler'
)
drag-active-overlay(
Expand Down Expand Up @@ -1087,17 +1086,15 @@ export default ({
}, 250),
// Handlers for file-upload via drag & drop action
dragStartHandler (e) {
// handler function for 'dragstart', 'dragover' events
const items = Array.from(e?.dataTransfer?.items) || []
if (items.some(entry => entry.kind === 'file')) { // check if the detected content is something attachable to the chat.
if (!this.dndState.isActive) {
this.dndState.isActive = true
}
e.preventDefault()
// handler function for 'dragstart', 'dragover' events.
// give user a correct feedback about what happens upon 'drop' action. (https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API)
e.dataTransfer.dropEffect = 'copy'
if (!this.dndState.isActive) {
this.dndState.isActive = true
}
// give user a correct feedback about what happens upon 'drop' action. (https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API)
e.dataTransfer.dropEffect = 'copy'
},
dragEndHandler (e) {
// handler function for 'dragleave', 'dragend', 'drop' events
Expand Down

0 comments on commit dd39cca

Please sign in to comment.