Skip to content

Commit 28a1607

Browse files
authored
Updated accesibility of codeblocks (#1064)
1 parent fd4aad2 commit 28a1607

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

src/components/Editor/CustomExtensions/CodeBlock/CodeBlockComponent.jsx

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useEffect, useState } from "react";
22

33
import { NodeViewWrapper, NodeViewContent } from "@tiptap/react";
4-
import classNames from "classnames";
54
import { Down } from "neetoicons";
65
import CopyToClipboardButton from "neetomolecules/CopyToClipboardButton";
76
import { Dropdown, Input } from "neetoui";
@@ -14,7 +13,6 @@ const { Menu, MenuItem } = Dropdown;
1413

1514
const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
1615
const [keyword, setKeyword] = useState("");
17-
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
1816

1917
const { t } = useTranslation();
2018

@@ -37,21 +35,15 @@ const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
3735
return (
3836
<NodeViewWrapper data-cy="neeto-editor-code-block">
3937
<pre>
40-
<div
41-
className={classNames("neeto-editor-codeblock-options", {
42-
"neeto-editor-codeblock-options--open": isDropdownOpen,
43-
})}
44-
>
38+
<div className="neeto-editor-codeblock-options" contentEditable={false}>
4539
<Dropdown
4640
appendTo={() => document.body}
4741
buttonSize="small"
4842
buttonStyle="secondary"
4943
icon={Down}
50-
isOpen={isDropdownOpen}
5144
label={node.attrs?.language || t("neetoEditor.common.auto")}
5245
strategy="fixed"
53-
onClick={() => setIsDropdownOpen(isOpen => !isOpen)}
54-
onClose={() => setIsDropdownOpen(false)}
46+
zIndex={99999}
5547
>
5648
<Input
5749
autoFocus

src/styles/editor/_editor-content.scss

+1-18
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,12 @@
135135
padding: 32px 12px 12px 12px;
136136

137137
.neeto-editor-codeblock-options {
138+
display: flex;
138139
position: absolute;
139-
display: none;
140140
gap: 4px;
141141
align-items: center;
142142
top: 4px;
143143
right: 4px;
144-
transition: opacity 150ms ease-in-out, transform 150ms ease-in-out;
145-
transform: scale(0);
146-
transition-delay: 50ms;
147144

148145
&__menu {
149146
display: flex;
@@ -154,20 +151,6 @@
154151
&__input {
155152
margin: 4px 4px;
156153
}
157-
158-
&--open {
159-
display: flex;
160-
opacity: 1;
161-
transform: scale(1);
162-
}
163-
}
164-
165-
&:hover {
166-
.neeto-editor-codeblock-options {
167-
display: flex;
168-
opacity: 1;
169-
transform: scale(1);
170-
}
171154
}
172155
}
173156

0 commit comments

Comments
 (0)