Skip to content

Commit e56ced6

Browse files
authored
Merge pull request #2420 from WPO-Foundation/fix-2406
Fix 2406- improve form usability in create experiments
2 parents a287cbb + 7004c48 commit e56ced6

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

www/assets/css/pagestyle2.css

+31-1
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,11 @@ h4.experiments_list_hed-recs {
10901090
margin: 0;
10911091
}
10921092

1093+
.experiment_description_go-multi label.experiment_pair_check:not(:has(input:checked)) + label:not(.experiment_pair_value-add) {
1094+
height: 3em;
1095+
overflow: hidden;
1096+
}
1097+
10931098
.experiment_description_go > label.experiment_pair_value {
10941099
border-left: 0;
10951100
margin-left: 0;
@@ -1104,6 +1109,7 @@ h4.experiments_list_hed-recs {
11041109
overflow: hidden;
11051110
text-indent: -999px;
11061111
display: inline-block;
1112+
position: absolute;
11071113
}
11081114

11091115
.experiment_pair_value_addbtn {
@@ -1135,11 +1141,14 @@ h4.experiments_list_hed-recs {
11351141
.experiment_description_go > label.experiment_pair_value-visible span {
11361142
font-weight: 500;
11371143
text-transform: initial;
1144+
position: relative;
1145+
max-width: 50%;
11381146
}
11391147

11401148
.experiment_description_go > label.experiment_pair_value-visible span em {
11411149
font-size: 0.8em;
11421150
color: #222;
1151+
display: block;
11431152
}
11441153

11451154
.experiment_description_go
@@ -1149,7 +1158,8 @@ h4.experiments_list_hed-recs {
11491158
flex: 1 1 auto;
11501159
}
11511160

1152-
.experiment_description_go > label.experiment_pair_value input {
1161+
.experiment_description_go > label.experiment_pair_value input,
1162+
.experiment_description_go > label.experiment_pair_value textarea {
11531163
width: 14em;
11541164
margin: 0;
11551165
padding: 1.45em;
@@ -1159,6 +1169,26 @@ h4.experiments_list_hed-recs {
11591169
line-height: 1;
11601170
}
11611171

1172+
.experiment_description_go > label.experiment_pair_value textarea {
1173+
width: calc(100% - 4em);
1174+
display: block;
1175+
box-sizing: border-box;
1176+
margin: 0 1em 1em 3em;
1177+
padding: 1em;
1178+
height: 10em;
1179+
border: 0;
1180+
max-width: none;
1181+
line-height: 1.6;
1182+
white-space: nowrap;
1183+
overflow: auto;
1184+
}
1185+
1186+
.experiment_description_go > label.experiment_pair_value textarea:focus {
1187+
outline: none;
1188+
background: #fafafa;
1189+
border: 1px solid #ccc;
1190+
}
1191+
11621192
.experiments_foot {
11631193
display: flex;
11641194
justify-content: flex-end;

www/experiments.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,14 @@ function observationHTML($parts)
325325
$out .= <<<EOT
326326
</div>
327327
<div class="experiment_description_go experiment_description_go-multi">
328-
<label class="experiment_pair_check"><input type="checkbox" name="recipes[]" value="{$expNum}-{$exp->expvar}">Run with:</label>
328+
<label class="experiment_pair_check"><input type="checkbox" name="recipes[]" value="{$expNum}-{$exp->expvar}">Run this Experiment with:</label>
329329
EOT;
330330
$addmore = $exp->addmore ? ' experiment_pair_value-add' : '';
331331

332332
foreach ($exp->expfields as $field) {
333333
if ($field->type === "text") {
334334
$out .= <<<EOT
335-
<label class="experiment_pair_value-visible {$addmore}"><span>{$field->label}: </span><input type="{$field->type}" name="{$expNum}-{$exp->expvar}[]"></label>
335+
<label class="experiment_pair_value-visible {$addmore}"><span>{$field->label} </span><input type="{$field->type}" name="{$expNum}-{$exp->expvar}[]"></label>
336336
EOT;
337337
} else {
338338
$out .= <<<EOT
@@ -348,11 +348,12 @@ function observationHTML($parts)
348348
}
349349
} elseif ($exp->expvar && !$exp->expval && $textinput) {
350350
if ($experimentEnabled) {
351+
$placeholderEncodedVal = htmlentities('<script src="https://example.com/test.js"></script>');
351352
$out .= <<<EOT
352353
</div>
353-
<div class="experiment_description_go">
354-
<label class="experiment_pair_check"><input type="checkbox" name="recipes[]" value="{$expNum}-{$exp->expvar}">Run with:</label>
355-
<label class="experiment_pair_value"><span>Value: </span><input type="text" name="{$expNum}-{$exp->expvar}[]" placeholder="experiment value..."></label>
354+
<div class="experiment_description_go experiment_description_go-multi">
355+
<label class="experiment_pair_check"><input type="checkbox" name="recipes[]" value="{$expNum}-{$exp->expvar}">Run this Experiment with:</label>
356+
<label class="experiment_pair_value"><span>Value: </span><textarea name="{$expNum}-{$exp->expvar}[]" placeholder="{$placeholderEncodedVal}"></textarea></label>
356357
357358
</div>
358359
EOT;

www/experiments/custom.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$category = "Custom";
44
$assessment[$category]["opportunities"][] = array(
55
"title" => "Add HTML to document",
6-
"desc" => "These experiments allow you to add arbitrary html to a page, which can for example, enable to you test the impact of adding script tags.",
6+
"desc" => "These experiments allow you to add arbitrary html to a page, which can for example, enable to you test the impact of adding scripts, 3rd-party tags, or resource hints.",
77
"examples" => array(),
88
"experiments" => array(
99
(object) [

0 commit comments

Comments
 (0)