From 7bd4089a269490941236c020a040f104b9748ebe Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Wed, 26 Apr 2023 09:49:35 +0200 Subject: [PATCH] Drag & Drop: fix JavaScript error related to JX.$(undefined) Summary: This change fixes the following recent JavaScript error: Error: Empty ID passed to JX.$()! The regression was introduced here: 90f9da643d1622bcfff3a8903159aeefd1b42520 Closes T15272 Test Plan: - with this change I was able to open Conpherence Persistent Chat and Drop a file Reviewers: O1 Blessed Committers, Dylsss, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: Dylsss, speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15272 Differential Revision: https://we.phorge.it/D25134 --- .../js/core/behavior-drag-and-drop-textarea.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/webroot/rsrc/js/core/behavior-drag-and-drop-textarea.js b/webroot/rsrc/js/core/behavior-drag-and-drop-textarea.js index 879a6a086d..4d8629cd8c 100644 --- a/webroot/rsrc/js/core/behavior-drag-and-drop-textarea.js +++ b/webroot/rsrc/js/core/behavior-drag-and-drop-textarea.js @@ -27,11 +27,15 @@ JX.behavior('aphront-drag-and-drop-textarea', function(config) { drop.listen('didUpload', function(file) { JX.TextAreaUtils.insertFileReference(target, file); - var metadata = new JX.RemarkupMetadata(config.remarkupMetadataValue, - config.remarkupMetadataID); - var phids = metadata.getMetadata('attachedFilePHIDs', []); - phids.push(file.getPHID()); - metadata.setMetadata('attachedFilePHIDs', phids); + if(config.remarkupMetadataID) { + // Try to auto-attach files by default + // https://we.phorge.it/T15106 + var metadata = new JX.RemarkupMetadata(config.remarkupMetadataValue, + config.remarkupMetadataID); + var phids = metadata.getMetadata('attachedFilePHIDs', []); + phids.push(file.getPHID()); + metadata.setMetadata('attachedFilePHIDs', phids); + } }); drop.start();