|
7 | 7 | } from "../../helpers/misc";
|
8 | 8 | import * as svg from "../../helpers/svg";
|
9 | 9 | import { Context } from "../../typing/context";
|
10 |
| -import { OpenOverlay } from "../../typing/open-overlay"; |
11 | 10 | import { RectData } from "../../typing/rect-data";
|
12 | 11 | import { WaterfallEntry } from "../../typing/waterfall";
|
13 | 12 | import { getIndicatorIcons } from "./svg-indicators";
|
@@ -80,196 +79,44 @@ export function createRow(context: Context, index: number,
|
80 | 79 |
|
81 | 80 | rowSubComponents.appendRequestLabels(rowName, requestNumberLabel, shortLabel, fullLabel);
|
82 | 81 |
|
83 |
| - // const onOpenOverlayFocusOut = (evt: KeyboardEvent) => { |
84 |
| - // if (evt.which !== 9) { |
85 |
| - // return; // only handle tabs |
86 |
| - // } |
87 |
| - // const isUpward = evt.shiftKey; |
88 |
| - // console.log("onActiveFocusOut", isUpward); |
89 |
| - // }; |
90 |
| - |
91 |
| - // accordeon a11y guide |
92 |
| - // https://www.w3.org/TR/wai-aria-practices-1.1/#accordion |
93 | 82 | context.pubSub.subscribeToSpecificOverlayChanges(index, (change) => {
|
94 |
| - openOverlay = (change.type === "open") ? change.changedOverlay : undefined; |
| 83 | + hasOpenOverlay = (change.type === "open"); |
95 | 84 | });
|
96 | 85 | if (index > 0) {
|
97 | 86 | context.pubSub.subscribeToSpecificOverlayChanges(index - 1, (change) => {
|
98 |
| - prevOpenOverlay = (change.type === "open") ? change.changedOverlay : undefined; |
| 87 | + hasPrevOpenOverlay = (change.type === "open"); |
99 | 88 | });
|
100 | 89 | }
|
101 | 90 |
|
102 |
| - let isPoinerClick = false; |
103 |
| - let openOverlay: OpenOverlay; |
104 |
| - /** Poiter to the previous open Oberlay (if exist) */ |
105 |
| - let prevOpenOverlay: OpenOverlay; |
106 |
| - // let showDetailsTimeout: number; |
107 |
| - |
108 |
| - |
109 |
| - |
110 |
| - // const enterOverlaySetup = (isDownwards: boolean, openOverlay: OpenOverlay) => { |
111 |
| - // const overlayEl = context.overlayManager.getOpenOverlayDomEl(openOverlay); |
112 |
| - // /** Top header el */ |
113 |
| - // const firstFocusEl = overlayEl.getElementsByTagName("a")[0]; |
114 |
| - // /** All focusable elements */ |
115 |
| - // const allFocusEl = overlayEl.querySelectorAll(":scope a, :scope button"); |
116 |
| - // const lastTab = getLastItemOfNodeList(allFocusEl); |
117 |
| - // for (let i = allFocusEl.length - 1; i <= 0 i--) { |
118 |
| - // const el = allFocusEl.item(i); |
119 |
| - // el.setAttribute("tabindex", "0"); |
120 |
| - // } |
121 |
| - // console.log(allFocusEl) |
122 |
| - |
123 |
| - // const onOverlayExit = () => { |
124 |
| - // console.log("Implement me"); |
125 |
| - // for (let i = allFocusEl.length - 1; i <= 0 i--) { |
126 |
| - // const el = allFocusEl.item(i); |
127 |
| - // el.setAttribute("tabindex", "-1"); |
128 |
| - // } |
129 |
| - // lastTab.removeEventListener("keypress", onLastElKeypress); |
130 |
| - // }; |
131 |
| - |
132 |
| - // const onLastElKeypress = (evt: KeyboardEvent) => { |
133 |
| - // if (isTabDown(evt)) { |
134 |
| - // evt.preventDefault(); |
135 |
| - // onOverlayExit(); |
136 |
| - // } |
137 |
| - // }; |
138 |
| - // lastTab.addEventListener("keypress", onLastElKeypress) |
139 |
| - // firstFocusEl.focus(); |
140 |
| - // }; |
| 91 | + let hasOpenOverlay: boolean; |
| 92 | + let hasPrevOpenOverlay: boolean; |
141 | 93 |
|
142 |
| - |
143 |
| - |
144 |
| - |
145 |
| - // triggered before click by touch and mouse devices |
146 |
| - rowItem.addEventListener("mouseup", () => { |
147 |
| - isPoinerClick = true; |
148 |
| - }); |
149 | 94 | rowItem.addEventListener("click", (evt: MouseEvent) => {
|
150 |
| - isPoinerClick = false; |
151 | 95 | onDetailsOverlayShow(evt);
|
152 | 96 | });
|
153 | 97 | rowItem.addEventListener("keydown", (evt: KeyboardEvent) => {
|
154 | 98 | // on enter
|
155 | 99 | if (evt.which === 32) {
|
156 |
| - evt.preventDefault(); |
157 |
| - onDetailsOverlayShow(evt); |
158 |
| - return; |
| 100 | + return onDetailsOverlayShow(evt); |
159 | 101 | }
|
160 | 102 |
|
161 |
| - // // moving down into overlay |
162 |
| - // if (isTabDown(evt) && openOverlay) { |
163 |
| - // console.log("moving down into overlay"); |
164 |
| - // evt.preventDefault(); |
165 |
| - // const overlayEl = context.overlayManager.getOpenOverlayDomEl(openOverlay); |
166 |
| - // /** Top header el */ |
167 |
| - // const firstFocusEl = overlayEl.getElementsByTagName("a")[0]; |
168 |
| - // const lastTab = getLastItemOfNodeList(overlayEl.getElementsByClassName("tab-button") as |
169 |
| - // NodeListOf<HTMLButtonElement>); |
170 |
| - |
171 |
| - // // Move out up the the top, to the node el |
172 |
| - // firstFocusEl.addEventListener("keydown", (inOverlayEvt: KeyboardEvent) => { |
173 |
| - // // IE & Edge do not support `focus()` in SVG |
174 |
| - // if (isTabUp(inOverlayEvt) && typeof (rowItem as any).focus === "function") { |
175 |
| - // console.log("Move out up the the top, to the node el"); |
176 |
| - // inOverlayEvt.preventDefault(); |
177 |
| - // console.log("rowItem in `nextFocusEl.on keydown with tab+shift`", rowItem); |
178 |
| - // (rowItem as any).focus(); |
179 |
| - // } |
180 |
| - // }); |
181 |
| - |
182 |
| - // console.log("lastTab", lastTab); |
183 |
| - // // Move out down at the end |
184 |
| - // lastTab.addEventListener("keydown", (inOverlayEvt: KeyboardEvent) => { |
185 |
| - // // IE & Edge do not support `focus()` in SVG |
186 |
| - // if (isTabDown(inOverlayEvt) && typeof (rowItem as any).focus === "function") { |
187 |
| - // console.log("Move out down at the end"); |
188 |
| - // if (rowItem.nextSibling) { |
189 |
| - // inOverlayEvt.preventDefault(); |
190 |
| - // // not last in chart |
191 |
| - // (rowItem.nextSibling as any).focus(); |
192 |
| - // } else { |
193 |
| - // //last in chart |
194 |
| - // console.log("last in chart") |
195 |
| - // inOverlayEvt.preventDefault(); |
196 |
| - // } |
197 |
| - // } else if (isTabDown(inOverlayEvt)) { |
198 |
| - // console.log(">>>"); |
199 |
| - // } |
200 |
| - // }); |
201 |
| - // firstFocusEl.focus(); |
202 |
| - // return; |
203 |
| - // // evt.cancelBubble = true; |
204 |
| - // } |
205 |
| - |
206 |
| - // // moving up into overlay |
207 |
| - // if (isTabUp(evt) && prevOpenOverlay) { |
208 |
| - // console.log("moving up into overlay"); |
209 |
| - // evt.preventDefault(); |
210 |
| - // const prevOverlayEl = context.overlayManager.getOpenOverlayDomEl(prevOpenOverlay); |
211 |
| - // const lastTab = getLastItemOfNodeList(prevOverlayEl.getElementsByClassName("tab-button") as |
212 |
| - // NodeListOf<HTMLButtonElement>); |
213 |
| - // lastTab.focus(); |
214 |
| - // return; |
215 |
| - // } |
216 |
| - |
217 |
| - // // tab without open overlays around |
218 |
| - if (isTabUp(evt) && !prevOpenOverlay && index > 0) { |
| 103 | + // tab without open overlays around |
| 104 | + if (isTabUp(evt) && !hasPrevOpenOverlay && index > 0) { |
219 | 105 | rowItem.previousSibling.previousSibling.lastChild.lastChild.dispatchEvent(new MouseEvent("mouseenter"));
|
220 | 106 | return;
|
221 | 107 | }
|
222 |
| - if (isTabDown(evt) && !openOverlay) { |
| 108 | + if (isTabDown(evt) && !hasOpenOverlay) { |
223 | 109 | if (rowItem.nextSibling && rowItem.nextSibling.nextSibling) {
|
224 | 110 | rowItem.nextSibling.nextSibling.lastChild.lastChild.dispatchEvent(new MouseEvent("mouseenter"));
|
225 | 111 | }
|
226 |
| - // else { |
227 |
| - // console.log("Sort this out > tab without open overlays around"); |
228 |
| - // if (context.overlayManager.hasOpenOverlays()) { |
229 |
| - // const lastTab = getLastItemOfNodeList(context.overlayManager.getLastOpenOverlayDomEl() |
230 |
| - // .getElementsByClassName("tab-button") as NodeListOf<HTMLButtonElement>); |
231 |
| - // console.log("END", lastTab); |
232 |
| - // lastTab.focus(); |
233 |
| - // } |
234 |
| - // // prev |
235 |
| - // // do not prevent default, so the focus moves on |
236 |
| - // } |
237 | 112 | return;
|
238 | 113 | }
|
239 |
| - // // Not handled |
240 |
| - // if (evt.which === 9) { |
241 |
| - // console.log("go to next/prev thing"); |
242 |
| - // } |
243 | 114 | });
|
244 | 115 |
|
245 |
| - // rowItem.addEventListener("keyup", (evt: KeyboardEvent) => { |
246 |
| - // if (evt.which === 9) { |
247 |
| - // //document.activeElement === rowItem |
248 |
| - // console.log("keydown"); |
249 |
| - // rowName.dispatchEvent(new MouseEvent("mouseenter")); |
250 |
| - // window["eventsStore"]["key"].push(evt); |
251 |
| - // } |
252 |
| - // }); |
253 |
| - |
254 |
| - |
255 |
| - // rowItem.addEventListener("focusin", (evt: FocusEvent) => { |
256 |
| - // console.log("in", isPoinerClick); |
257 |
| - // // const test = new MouseEvent("mouseenter"); |
258 |
| - // rowName.dispatchEvent(new MouseEvent("mouseenter")); |
259 |
| - // window["eventsStore"]["mouse"].push(evt); |
260 |
| - // }); |
261 |
| - |
262 |
| - |
263 | 116 | rowItem.addEventListener("focusout", () => {
|
264 | 117 | rowName.dispatchEvent(new MouseEvent("mouseleave"));
|
265 | 118 | });
|
266 | 119 |
|
267 |
| - // rowItem.addEventListener("click", (evt) => { |
268 |
| - // console.log("click", evt); |
269 |
| - // onDetailsOverlayShow(evt); |
270 |
| - // }); |
271 |
| - |
272 |
| - |
273 | 120 | flexScaleHolder.appendChild(rowBar);
|
274 | 121 | leftFixedHolder.appendChild(clipPathElProto.cloneNode(true));
|
275 | 122 | leftFixedHolder.appendChild(rowName);
|
|
0 commit comments