diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php
index 0725e520b2d3f84fe9e7b2471a462223172ab3c6..f5cbb63e08315780ee584f73fb616e617fd82834 100644
--- a/apps/files_sharing/lib/Controller/ShareController.php
+++ b/apps/files_sharing/lib/Controller/ShareController.php
@@ -445,7 +445,8 @@ class ShareController extends AuthPublicShareController {
 		\OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
 		\OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);
 
-		$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts');
+		$event = new GenericEvent(null, ['share' => $share]);
+		$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts', $event);
 
 		$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
 		$csp->addAllowedFrameDomain('\'self\'');
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index ea9bd8316e20366a0a41f660dc1300af3ce62ea5..97e234ca22c30cafebcdeef8a9a0574a789733a9 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -254,7 +254,12 @@ class ShareControllerTest extends \Test\TestCase {
 
 		$this->eventDispatcher->expects($this->once())
 			->method('dispatch')
-			->with('OCA\Files_Sharing::loadAdditionalScripts');
+			->with(
+				'OCA\Files_Sharing::loadAdditionalScripts',
+				$this->callback(function($event) use ($share) {
+					return $event->getArgument('share') === $share;
+				})
+			);
 
 		$this->l10n->expects($this->any())
 			->method('t')
@@ -374,7 +379,12 @@ class ShareControllerTest extends \Test\TestCase {
 
 		$this->eventDispatcher->expects($this->once())
 			->method('dispatch')
-			->with('OCA\Files_Sharing::loadAdditionalScripts');
+			->with(
+				'OCA\Files_Sharing::loadAdditionalScripts',
+				$this->callback(function($event) use ($share) {
+					return $event->getArgument('share') === $share;
+				})
+			);
 
 		$this->l10n->expects($this->any())
 			->method('t')