From e3cec212520a0686e4cb63979a2d40674e4d53fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 15 Jun 2020 10:32:35 +0200 Subject: [PATCH] Preserve the scroll position in styleAdd when saving Closes #3266 --- wcfsetup/install/files/acp/templates/styleAdd.tpl | 4 ++++ .../files/lib/acp/form/StyleAddForm.class.php | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/templates/styleAdd.tpl b/wcfsetup/install/files/acp/templates/styleAdd.tpl index 93b8f8b8ee..a80ad128d5 100644 --- a/wcfsetup/install/files/acp/templates/styleAdd.tpl +++ b/wcfsetup/install/files/acp/templates/styleAdd.tpl @@ -1018,6 +1018,7 @@
+
{lang}wcf.acp.style.advanced.individualScss.description{/lang}
@@ -1032,6 +1033,7 @@
+
{if $errorField == 'overrideScssCustom'} @@ -1060,6 +1062,7 @@
+
{lang}wcf.acp.style.advanced.individualScss.description{/lang}
@@ -1074,6 +1077,7 @@
+
{if $errorField == 'overrideScss'} diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 15ffa0d049..b26656fb43 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -12,6 +12,7 @@ use wcf\system\exception\UserInputException; use wcf\system\language\I18nHandler; use wcf\system\Regex; use wcf\system\WCF; +use wcf\util\ArrayUtil; use wcf\util\DateUtil; use wcf\util\FileUtil; use wcf\util\StringUtil; @@ -199,6 +200,12 @@ class StyleAddForm extends AbstractForm { */ public $specialVariables = []; + /** + * current scroll offsets before submitting the form + * @var integer[] + */ + public $scrollOffsets = []; + /** * @inheritDoc */ @@ -281,6 +288,9 @@ class StyleAddForm extends AbstractForm { if (isset($_POST['styleVersion'])) $this->styleVersion = StringUtil::trim($_POST['styleVersion']); if (isset($_POST['templateGroupID'])) $this->templateGroupID = intval($_POST['templateGroupID']); if (isset($_POST['apiVersion']) && in_array($_POST['apiVersion'], Style::$supportedApiVersions)) $this->apiVersion = $_POST['apiVersion']; + + // codemirror scroll offset + if (isset($_POST['scrollOffsets']) && is_array($_POST['scrollOffsets'])) $this->scrollOffsets = ArrayUtil::toIntegerArray($_POST['scrollOffsets']); } /** @@ -652,7 +662,8 @@ class StyleAddForm extends AbstractForm { 'tmpHash' => $this->tmpHash, 'variables' => $this->variables, 'supportedApiVersions' => Style::$supportedApiVersions, - 'newVariables' => $this->newVariables + 'newVariables' => $this->newVariables, + 'scrollOffsets' => $this->scrollOffsets, ]); } -- 2.20.1