Skip to content

Commit

Permalink
DND + alert fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmeese7 committed Feb 9, 2024
1 parent e3f0f36 commit c118321
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 3 additions & 1 deletion frontend/client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,9 @@ export type WindowAttributes = {
/**
* If window should have the default drop action.
*/
droppable?: boolean;
droppable?: boolean | {
dataTransferProperty?: 'files' | 'items';
};

/**
* Minimum dimension.
Expand Down
2 changes: 1 addition & 1 deletion frontend/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meese-os/client",
"version": "1.0.9",
"version": "1.0.10",
"description": "meeseOS client",
"scripts": {
"test": "npm run eslint && npm run stylelint && npm run jest",
Expand Down
11 changes: 7 additions & 4 deletions frontend/client/src/utils/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ const retval = (fn, ...args) => {
return true;
};

const getDataTransfer = (ev, type) => {
const getDataTransfer = (ev, type, dataTransferProperty) => {
let files = [];
let data;

if (ev.dataTransfer) {
files = ev.dataTransfer.files ? Array.from(ev.dataTransfer.files) : [];
files = ev.dataTransfer[dataTransferProperty]
? Array.from(ev.dataTransfer[dataTransferProperty])
: [];

try {
const transfer = ev.dataTransfer.getData(type);
Expand Down Expand Up @@ -200,10 +202,11 @@ export const draggable = (el, options = {}) => {
* @returns {DroppableInstance}
*/
export const droppable = (el, options = {}) => {
const { strict, type, effect, ondragenter, ondragover, ondragleave, ondrop } =
const { strict, type, effect, dataTransferProperty, ondragenter, ondragover, ondragleave, ondrop } =
{
type: "application/json",
effect: "move",
dataTransferProperty: "files",
ondragenter: () => true,
ondragover: () => true,
ondragleave: () => true,
Expand Down Expand Up @@ -242,7 +245,7 @@ export const droppable = (el, options = {}) => {
return false;
}

const { files, data } = getDataTransfer(ev, type);
const { files, data } = getDataTransfer(ev, type, dataTransferProperty);

ev.stopPropagation();
ev.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion frontend/dialogs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meese-os/dialogs",
"version": "1.0.4",
"version": "1.0.5",
"description": "meeseOS Dialogs",
"scripts": {
"test": "npm run eslint && npm run stylelint",
Expand Down
7 changes: 1 addition & 6 deletions frontend/dialogs/src/dialogs/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ export default class AlertDialog extends Dialog {

if (this.args.type === "error") {
const { error } = this.args;
const msg =
error instanceof Error
? error.stack
? error.stack
: error
: String(error);
const msg = error instanceof Error ? `${error.message}\n\n${error.stack || 'No stack'}` : error;

children.push(
h(TextareaField, {
Expand Down

0 comments on commit c118321

Please sign in to comment.