Skip to content

Commit 4e7a050

Browse files
committed
Button accessibility and a confirm dialogue before clearing all columns
1 parent 05795c9 commit 4e7a050

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

interfaces/manage-columns/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ class TpenManageColumns extends HTMLElement {
131131
outline: var(--primary-color) 1px solid;
132132
outline-offset: -1.5px;
133133
}
134+
button#createColumnBtn:focus-visible, button#clearSelectionBtn:focus-visible,
135+
button#mergeColumnBtn:focus-visible, button#extendColumnBtn:focus-visible {
136+
background-color: var(--primary-light);
137+
outline: 2px solid var(--primary-color);
138+
outline-offset: 2px;
139+
}
134140
.disabled {
135141
pointer-events: none;
136142
opacity: 0.6;
@@ -207,6 +213,11 @@ class TpenManageColumns extends HTMLElement {
207213
outline: var(--primary-color) 1px solid;
208214
outline-offset: -1.5px;
209215
}
216+
.merge-label-btn:focus-visible, .extend-label-btn:focus-visible {
217+
background-color: var(--primary-light);
218+
outline: 2px solid var(--primary-color);
219+
outline-offset: 2px;
220+
}
210221
.merge-label-btn[data-selected="true"], .extend-label-btn[data-selected="true"] {
211222
border: 8px solid var(--primary-color);
212223
}
@@ -581,11 +592,13 @@ class TpenManageColumns extends HTMLElement {
581592
handleModeChange() {
582593
if (this.extendColumnCheckbox.checked || this.mergeColumnsCheckbox.checked) {
583594
this.createBtn.classList.add("disable-button")
595+
this.createBtn.disabled = true
584596
this.columnTitleInput.disabled = true
585597
const workspaceToolbar = this.shadowRoot.querySelectorAll('.toolbar')[1]
586598
workspaceToolbar.style.justifyContent = 'space-between'
587599
} else {
588600
this.createBtn.classList.remove("disable-button")
601+
this.createBtn.disabled = false
589602
this.columnTitleInput.disabled = false
590603
const workspaceToolbar = this.shadowRoot.querySelectorAll('.toolbar')[1]
591604
workspaceToolbar.innerHTML = `
@@ -597,17 +610,21 @@ class TpenManageColumns extends HTMLElement {
597610

598611
if (this.extendColumnCheckbox.checked) {
599612
this.mergeColumnsCheckbox.classList.add("disable-other")
613+
this.mergeColumnsCheckbox.disabled = true
600614
this.mergeColumnsLabel.classList.add("disable-other")
601615
} else {
602616
this.mergeColumnsCheckbox.classList.remove("disable-other")
617+
this.mergeColumnsCheckbox.disabled = false
603618
this.mergeColumnsLabel.classList.remove("disable-other")
604619
}
605620

606621
if (this.mergeColumnsCheckbox.checked) {
607622
this.extendColumnCheckbox.classList.add("disable-other")
623+
this.extendColumnCheckbox.disabled = true
608624
this.extendColumnLabel.classList.add("disable-other")
609625
} else {
610626
this.extendColumnCheckbox.classList.remove("disable-other")
627+
this.extendColumnCheckbox.disabled = false
611628
this.extendColumnLabel.classList.remove("disable-other")
612629
}
613630

@@ -1057,6 +1074,29 @@ class TpenManageColumns extends HTMLElement {
10571074
}
10581075

10591076
async clearAllSelections() {
1077+
if (!this.existingColumns.length) return
1078+
1079+
TPEN.eventDispatcher.dispatch("tpen-confirm", {
1080+
message: "This will clear all columns. This action cannot be undone.",
1081+
positiveButtonText: "Clear All",
1082+
negativeButtonText: "Cancel"
1083+
})
1084+
1085+
const confirmed = await new Promise(resolve => {
1086+
const onPositive = () => {
1087+
TPEN.eventDispatcher.off("tpen-confirm-negative", onNegative)
1088+
resolve(true)
1089+
}
1090+
const onNegative = () => {
1091+
TPEN.eventDispatcher.off("tpen-confirm-positive", onPositive)
1092+
resolve(false)
1093+
}
1094+
TPEN.eventDispatcher.one("tpen-confirm-positive", onPositive)
1095+
TPEN.eventDispatcher.one("tpen-confirm-negative", onNegative)
1096+
})
1097+
1098+
if (!confirmed) return
1099+
10601100
try {
10611101
const res = await fetch(`${TPEN.servicesURL}/project/${this.projectID}/page/${this.annotationPageID}/clear-columns`, {
10621102
method: 'DELETE',

0 commit comments

Comments
 (0)