Skip to content

Commit 3a36c64

Browse files
committed
resolve feedback issues
1 parent 7d0e158 commit 3a36c64

File tree

5 files changed

+135
-151
lines changed

5 files changed

+135
-151
lines changed

client/modules/IDE/components/Editor.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ class Editor extends React.Component {
346346

347347
showHint(_cm) {
348348
const hintOptions = {
349+
_fontSize: this.props.fontSize,
349350
completeSingle: false
350351
// completeOnSingleClick: false,
351-
// closeOnUnfocus: false
352+
// closeOnUnfocus: false,
352353
// closeOnPick: false
353354
};
354355

client/modules/IDE/components/EditorShowHint.jsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174

175175
function getText(completion) {
176176
if (typeof completion == "string") return completion;
177-
else return completion.text;
177+
else return completion.item.text;
178178
}
179179

180180
function buildKeyMap(completion, handle) {
@@ -235,23 +235,30 @@
235235
var ownerDocument = cm.getInputField().ownerDocument;
236236
var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow;
237237

238+
var fontSize = completion.options._fontSize;
239+
238240
var hints = this.hints = ownerDocument.createElement("ul");
241+
hints.setAttribute("role", "listbox")
242+
hints.setAttribute("aria-expanded", "true")
239243
var theme = completion.cm.options.theme;
240244
hints.className = "CodeMirror-hints " + theme;
241245
this.selectedHint = data.selectedHint || 0;
242246

243247
var completions = data.list;
248+
244249
for (var i = 0; i < completions.length; ++i) {
245250
var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i];
246251
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
247252
if (cur.className != null) className = cur.className + " " + className;
248253
elt.className = className;
254+
if (i == this.selectedHint) elt.setAttribute("aria-selected", "true")
255+
elt.setAttribute("role", "option")
249256
if (cur.render) cur.render(elt, data, cur);
250257
else {
251258
const e = ownerDocument.createElement('p');
252259
const name = getText(cur);
253-
if (cur.type) {
254-
cur.displayText = `<span class="${cur.type}-name hint-name">${name}</span><span class="hint-type">${cur.type}</span>*`;
260+
if (cur.item && cur.item.type) {
261+
cur.displayText = `<span class="${cur.item.type}-name hint-name">${name}</span><span class="hint-type">${cur.item.type}</span>*`;
255262
cur.displayText = cur.displayText.replace('*', `<a href="https://p5js.org/reference/#/p5/${name}" onclick="event.stopPropagation()" target="_blank">&#10132;</a>`);
256263
}
257264
elt.appendChild(e);
@@ -280,6 +287,7 @@
280287
var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
281288
var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
282289
container.appendChild(hints);
290+
cm.getInputField().setAttribute("aria-autocomplete", "list")
283291

284292
var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect();
285293
var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false;
@@ -377,6 +385,9 @@
377385
this.completion.widget = null;
378386
if (this.hints.parentNode) this.hints.parentNode.removeChild(this.hints);
379387
this.completion.cm.removeKeyMap(this.keyMap);
388+
var input = this.completion.cm.getInputField()
389+
input.removeAttribute("aria-activedescendant")
390+
input.removeAttribute("aria-owns")
380391

381392
var cm = this.completion.cm;
382393
if (this.completion.options.closeOnUnfocus) {
@@ -404,9 +415,14 @@
404415
i = avoidWrap ? 0 : this.data.list.length - 1;
405416
if (this.selectedHint == i) return;
406417
var node = this.hints.childNodes[this.selectedHint];
407-
if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
418+
if (node) {
419+
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
420+
node.removeAttribute("aria-selected")
421+
}
408422
node = this.hints.childNodes[this.selectedHint = i];
409423
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
424+
node.setAttribute("aria-selected", "true")
425+
this.completion.cm.getInputField().setAttribute("aria-activedescendant", node.id)
410426
this.scrollToActive()
411427
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
412428
},

client/styles/abstracts/_variables.scss

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,22 @@ $themes: (
116116
form-secondary-title-color: $medium-dark,
117117
form-input-text-color: $dark,
118118
form-input-placeholder-text-color: $middle-light,
119-
form-navigation-options-color: $middle-dark
119+
form-navigation-options-color: $middle-dark,
120+
121+
hint-background-color: $white,
122+
hint-text-color: $dark,
123+
hint-item-border-bottom: 1px solid $lighter,
124+
hint-fun-text-color: #0B7CA9,
125+
hint-var-text-color: #D52889,
126+
hint-type-text-color: $middle-dark,
127+
hint-arrow-color: $lightest,
128+
hint-arrow-background-color: $p5js-pink,
129+
hint-item-hover-background-color: #f4f4f4,
130+
hint-item-active-text-color: unset,
131+
hint-item-active-background-color: #cfcfcf,
132+
hint-item-active-type-text-color: $white,
133+
hint-item-active-outline: none,
134+
hint-item-active-outline-offset: 0
120135
),
121136
dark: (
122137
logo-color: $p5js-pink,
@@ -196,7 +211,22 @@ $themes: (
196211

197212
form-title-color: $lightest,
198213
form-secondary-title-color: $medium-light,
199-
form-navigation-options-color: $middle-light
214+
form-navigation-options-color: $middle-light,
215+
216+
hint-background-color: $darker,
217+
hint-text-color: #E0D7D1,
218+
hint-item-border-bottom: 1px solid $middle-dark,
219+
hint-fun-text-color: #0F9DD7,
220+
hint-var-text-color: #DE4A9B,
221+
hint-type-text-color: #E0D7D1,
222+
hint-arrow-color: #FDFDFD,
223+
hint-arrow-background-color: $p5js-pink,
224+
hint-item-hover-background-color: $middle-dark,
225+
hint-item-active-text-color: $darker,
226+
hint-item-active-background-color: #cfcfcf,
227+
hint-item-active-type-text-color: $middle-dark,
228+
hint-item-active-outline: none,
229+
hint-item-active-outline-offset: 0
200230
),
201231
contrast: (
202232
logo-color: $yellow,
@@ -276,7 +306,22 @@ $themes: (
276306

277307
form-title-color: $lightest,
278308
form-secondary-title-color: $medium-light,
279-
form-navigation-options-color: $middle-light
309+
form-navigation-options-color: $middle-light,
310+
311+
hint-background-color: $darker,
312+
hint-text-color: #c1c1c1,
313+
hint-item-border-bottom: 1px solid #333,
314+
hint-fun-text-color: #00FFFF,
315+
hint-var-text-color: #FFA9D9,
316+
hint-type-text-color: #c1c1c1,
317+
hint-arrow-color: #333,
318+
hint-arrow-background-color: #F5DC23,
319+
hint-item-hover-background-color: #454545,
320+
hint-item-active-text-color: #FDFDFD,
321+
hint-item-active-background-color: unset,
322+
hint-item-active-type-text-color: #FDFDFD,
323+
hint-item-active-outline: 2px solid #FDFDFD,
324+
hint-item-active-outline-offset: -2px
280325
)
281326
);
282327

0 commit comments

Comments
 (0)