Skip to content

Commit c818eaa

Browse files
committed
Fix submission, fix some tests, improve tabbing + focus states
1 parent f8fbdf8 commit c818eaa

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

src/main/js/add-item.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ document.addEventListener("DOMContentLoaded", () => {
237237
var message = parseResponseFromCheckJobName(data);
238238
if (message !== "") {
239239
activateValidationMessage(message);
240+
setFieldValidationStatus("name", false);
241+
refreshSubmitButtonState();
240242
} else {
241243
activateValidationMessage("");
242244
setFieldValidationStatus("name", true);
@@ -308,7 +310,9 @@ document.addEventListener("DOMContentLoaded", () => {
308310
refreshSubmitButtonState();
309311
});
310312

311-
copyRadio.addEventListener("change", () => {
312-
copyFromInput.focus();
313-
});
313+
if (copyRadio !== null) {
314+
copyRadio.addEventListener("change", () => {
315+
copyFromInput.focus();
316+
});
317+
}
314318
});

src/main/js/add-item.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212

1313
// Make 'Duplicate an existing item' input not full width
14-
input {
14+
input[type="text"] {
1515
width: 100%;
1616
max-width: 400px;
1717
}

src/main/scss/components/_choice-list.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
}
4747

4848
&:active,
49-
&:focus-visible {
49+
&:has(input[type="radio"]:focus) {
5050
z-index: 10;
5151
border-radius: calc(var(--form-input-border-radius) / 2);
5252

@@ -79,7 +79,7 @@
7979

8080
&:hover,
8181
&:active,
82-
&:focus {
82+
&:has(input[type="radio"]:focus) {
8383
.jenkins-choice-list__item__icon::before {
8484
background: rgb(from var(--text-color-secondary) r g b / 0.1);
8585
box-shadow:
@@ -89,7 +89,7 @@
8989
}
9090
}
9191

92-
&:focus {
92+
&:has(input[type="radio"]:focus) {
9393
&::before {
9494
box-shadow: 0 0 0 0.2rem var(--text-color) !important;
9595
}
@@ -110,7 +110,7 @@
110110
&::before {
111111
box-shadow:
112112
inset var(--jenkins-border--subtle-shadow),
113-
inset 0 0 18px 18px var(--accent-color);
113+
inset 0 0 18px 18px var(--accent-color) !important;
114114
}
115115
}
116116

@@ -146,7 +146,8 @@
146146
}
147147

148148
label > input[type="radio"] {
149-
display: none;
149+
position: absolute;
150+
opacity: 0;
150151
}
151152

152153
&__icon {

src/main/scss/form/_input.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
width: 100%;
88
min-height: 2.375rem;
99
box-shadow: var(--form-input-glow);
10+
caret-color: var(--focus-input-border);
1011

1112
// Set height transition to 0s as vertical resizing has a delay/lag otherwise
1213
transition:

src/main/scss/form/_layout.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
--focus-input-border: var(--warning-color);
5858
--form-input-glow--focus: 0 0 0 0.25rem
5959
color-mix(in sRGB, var(--warning-color) 20%, transparent);
60-
61-
caret-color: var(--warning-color);
6260
}
6361

6462
&:has(> .validation-error-area .error) {
@@ -67,8 +65,6 @@
6765
--focus-input-border: var(--error-color);
6866
--form-input-glow--focus: 0 0 0 0.25rem
6967
color-mix(in sRGB, var(--error-color) 20%, transparent);
70-
71-
caret-color: var(--error-color);
7268
}
7369
}
7470

test/src/test/java/hudson/model/MyViewTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void testDoCreateItem() throws Exception {
8888
form.getInputByName("name").setValue("job");
8989
form.getInputByName("name").blur();
9090
// Select the item clicking on the first item type shown
91-
HtmlElement itemType = newItemPage.getFirstByXPath("//div[@class='category']/ul/li");
91+
HtmlElement itemType = newItemPage.getFirstByXPath("//div[@class='jenkins-choice-list']/div/label");
9292
itemType.click();
9393
rule.submit(form);
9494
Item item = rule.jenkins.getItem("job");

test/src/test/java/hudson/model/ViewTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,12 +894,12 @@ void newJob_xssPreventedInGetIconFilePathPattern() throws Exception {
894894

895895
HtmlPage page = wc.goTo("view/all/newJob");
896896

897-
Object resultIconChildrenCount = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .icon').children.length").getJavaScriptResult();
897+
Object resultIconChildrenCount = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .jenkins-choice-list__item__icon').children.length").getJavaScriptResult();
898898
assertThat(resultIconChildrenCount, instanceOf(Integer.class));
899899
int resultIconChildrenCountInt = (int) resultIconChildrenCount;
900900
assertEquals(1, resultIconChildrenCountInt);
901901

902-
Object resultImgAttributesCount = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .icon img').attributes.length").getJavaScriptResult();
902+
Object resultImgAttributesCount = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .jenkins-choice-list__item__icon img').attributes.length").getJavaScriptResult();
903903
assertThat(resultImgAttributesCount, instanceOf(Integer.class));
904904
int resultImgAttributesCountInt = (int) resultImgAttributesCount;
905905
assertEquals(1, resultImgAttributesCountInt);
@@ -929,7 +929,7 @@ void newJob_iconClassName() throws Exception {
929929

930930
HtmlPage page = wc.goTo("view/all/newJob");
931931

932-
Object resultSrc = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .icon img').src").getJavaScriptResult();
932+
Object resultSrc = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .jenkins-choice-list__item__icon img').src").getJavaScriptResult();
933933

934934
assertThat(resultSrc, instanceOf(String.class));
935935
String resultSrcString = (String) resultSrc;
@@ -944,7 +944,7 @@ void newJob_svg() throws Exception {
944944

945945
HtmlPage page = wc.goTo("view/all/newJob");
946946

947-
Object result = page.executeJavaScript("document.querySelector('.hudson_model_FreeStyleProject .icon svg')").getJavaScriptResult();
947+
Object result = page.executeJavaScript("document.querySelector('.hudson_model_FreeStyleProject .jenkins-choice-list__item__icon svg')").getJavaScriptResult();
948948
assertThat(result, instanceOf(SVGElement.class));
949949
SVGElement svg = (SVGElement) result;
950950
assertThat(svg.getClassName_js(), is("icon-xlg"));
@@ -962,7 +962,7 @@ void newJob_twoLetterIcon() throws Exception {
962962

963963
HtmlPage page = wc.goTo("view/all/newJob");
964964

965-
Object result = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .default-icon')").getJavaScriptResult();
965+
Object result = page.executeJavaScript("document.querySelector('." + customizableTLID.customId + " .jenkins-choice-list__item__icon')").getJavaScriptResult();
966966
assertThat(result, instanceOf(HTMLElement.class));
967967
HTMLElement resultHtml = (HTMLElement) result;
968968
HTMLElement spanA = (HTMLElement) resultHtml.getFirstElementChild();

0 commit comments

Comments
 (0)