Skip to content

Commit 11f5f84

Browse files
committed
Merge branch 'embed-dialog-a11y' of Arnei/opencast-admin-interface into develop
Pull request #1570 Fixing more a11y issues in the embed dialog
2 parents 75b900a + 042dfa7 commit 11f5f84

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

src/components/events/partials/modals/EmbeddingCodeModal.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ const EmbeddingCodeModal = ({
3131
}, []);
3232

3333
const copy = () => {
34-
const copyText = document.getElementById("social_embed-textarea") as HTMLTextAreaElement;
34+
const copyText = document.getElementById("social_embed-textarea");
3535
if (copyText) {
36-
copyText.select();
37-
document.execCommand("copy");
36+
const text = copyText.innerText;
37+
navigator.clipboard.writeText(text);
3838

3939
setCopySuccess(true);
4040
}
@@ -78,6 +78,13 @@ const EmbeddingCodeModal = ({
7878
setCopySuccess(false);
7979
};
8080

81+
const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
82+
if ((e.ctrlKey || e.metaKey) && e.key === "c") {
83+
e.preventDefault();
84+
copy();
85+
}
86+
};
87+
8188
return (
8289
<>
8390
{/* embed size buttons */}
@@ -142,14 +149,15 @@ const EmbeddingCodeModal = ({
142149

143150
{/* text area containing current iFrame code to copy*/}
144151
<div className="embedded-code-video">
145-
<textarea
152+
<code
146153
id="social_embed-textarea"
147-
className="social_embed-textarea embedded-code-textarea"
148-
rows={2}
149-
value={textAreaContent}
150-
cols={1}
154+
className="embedded-code-textarea"
151155
aria-label={t("EMBEDDING_CODE.EMBEDD_CODE_TEXTAREA_ARIA")}
152-
/>
156+
tabIndex={0}
157+
onKeyDown={handleKeyDown}
158+
>
159+
{textAreaContent}
160+
</code>
153161
</div>
154162

155163
{/* copy confirmation */}

src/styles/views/modals/_embedded-code.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,21 @@
9393
.embedded-code-video {
9494
text-align:center;
9595
margin-bottom: 20px;
96+
display: flex;
97+
justify-content: center;
9698
}
9799

98100
.embedded-code-textarea {
99101
font-size:12px;
100102
width:95%;
101103
overflow:auto;
102104
margin-top:5px;
103-
color:black;
105+
color: variables.$color-black;
106+
display: block;
107+
padding: 16px;
108+
border-radius: 10px;
109+
border: 1px solid variables.$color-darkgray;
110+
white-space: pre-wrap;
104111
}
105112

106113
.embedded-code-copy-to-clipboard {

0 commit comments

Comments
 (0)