Skip to content

Commit

Permalink
Merge branch 'main' into feat-strong-hash
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim authored Jan 27, 2025
2 parents 8eca87e + d2798fb commit 4c9276c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
- Fixed math parsing that could cause Web Chat to hang when processing certain LaTeX expressions, in PR [#5377](https://github.com/microsoft/BotFramework-WebChat/pull/5377), by [@OEvgeny](https://github.com/OEvgeny)
- Fixed long math formula should be scrollable, in PR [#5380](https://github.com/microsoft/BotFramework-WebChat/pull/5380), by [@compulim](https://github.com/compulim)
- Fixed [#4948](https://github.com/microsoft/BotFramework-WebChat/issues/4948). Microphone should stop after initial silence, in PR [#5385](https://github.com/microsoft/BotFramework-WebChat/pull/5385)
- Fixed [#5390](https://github.com/microsoft/BotFramework-WebChat/issues/5390). Fixed drop zone remaining visible when file is dropped outside of the zone, in PR [#5394](https://github.com/microsoft/BotFramework-WebChat/pull/5394), by [@OEvgeny](https://github.com/OEvgeny)

# Removed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 40 additions & 10 deletions __tests__/html/fluentTheme/dragAndDrop.upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,66 @@
dataTransfer.items.add(new File([new ArrayBuffer(100)], 'simple.txt'));

// WHEN: Dragging a file into document.
const dragEnterDocumentEvent = new DragEvent('dragenter', { dataTransfer });

dragEnterDocumentEvent.initEvent('dragenter', true, true);
const dragEnterDocumentEvent = new DragEvent('dragenter', {
bubbles: true,
cancelable: true,
dataTransfer
});

document.dispatchEvent(dragEnterDocumentEvent);

// THEN: Should render the drop zone.
await host.snapshot();

// WHEN: Dragging into the drop zone.
const dragEnterDropZoneEvent = new DragEvent('dragenter', { dataTransfer });

dragEnterDropZoneEvent.initEvent('dragenter', true, true);
const dragEnterDropZoneEvent = new DragEvent('dragenter', {
bubbles: true,
cancelable: true,
dataTransfer
});

document
.querySelector(`[data-testid="${WebChat.testIds['sendBoxDropZone']}"]`)
.dispatchEvent(dragEnterDropZoneEvent);

// THEN: Should render the drop zone.
// THEN: Should render element dropped.
await host.snapshot();

// WHEN: Dropping into the drop zone.
const dropEvent = new DragEvent('drop', { dataTransfer });

dropEvent.initEvent('drop', true, true);
const dropEvent = new DragEvent('drop', {
bubbles: true,
cancelable: true,
dataTransfer
});

document.querySelector(`[data-testid="${WebChat.testIds['sendBoxDropZone']}"]`).dispatchEvent(dropEvent);

// THEN: Should render the drop zone.
await host.snapshot();

// WHEN: Dragging a file into document.
const dragEnterDocumentEvent1 = new DragEvent('dragenter', {
bubbles: true,
cancelable: true,
dataTransfer
});

document.dispatchEvent(dragEnterDocumentEvent1);

// THEN: Should render the drop zone.
await host.snapshot();

// WHEN: Dropping out of the drop zone.
const dropEvent1 = new DragEvent('drop', {
bubbles: true,
cancelable: true,
dataTransfer
});

document.body.dispatchEvent(dropEvent1);

// THEN: Should render single element dropped.
await host.snapshot();
});
</script>
</body>
Expand Down
14 changes: 11 additions & 3 deletions packages/fluent-theme/src/components/dropZone/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,22 @@ const DropZone = (props: { readonly onFilesAdded: (files: File[]) => void }) =>
setDropZoneState(false);
};

document.addEventListener('dragenter', handleDragEnter, false);
document.addEventListener('dragleave', handleDragLeave, false);
document.addEventListener('dragend', handleDragEnd, false);
const handleDocumentDrop = (event: DragEvent) => {
if (!dropZoneRef.current?.contains(event.target as Node)) {
handleDragEnd();
}
};

document.addEventListener('dragenter', handleDragEnter);
document.addEventListener('dragleave', handleDragLeave);
document.addEventListener('dragend', handleDragEnd);
document.addEventListener('drop', handleDocumentDrop);

return () => {
document.removeEventListener('dragenter', handleDragEnter);
document.removeEventListener('dragleave', handleDragLeave);
document.removeEventListener('dragend', handleDragEnd);
document.removeEventListener('drop', handleDocumentDrop);
};
}, [setDropZoneState]);

Expand Down

0 comments on commit 4c9276c

Please sign in to comment.