Skip to content

Commit 64f4ab3

Browse files
committed
minor changes
1 parent 82d021c commit 64f4ab3

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

playground.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ section a:focus {
157157
background-color: var(--amber-100);
158158
}
159159

160+
section pre {
161+
font-size: 16px;
162+
}
163+
160164
section div[tabindex] {
161165
padding: 10px;
162166
font-size: 16px;

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ const tabwrap = (rootElement : HTMLElement) : void => {
141141
? event.key === 'Tab'
142142
: event.keyCode === 9;
143143
shiftKeyDetected = event.shiftKey;
144-
activeElement = event.target !== null
145-
? event.target as HTMLElement
146-
: null;
144+
// activeElement = event.target !== null
145+
// ? event.target as HTMLElement
146+
// : null;
147147
};
148148

149149
// @ts-ignore no overload matches
@@ -180,17 +180,17 @@ const tabwrap = (rootElement : HTMLElement) : void => {
180180
setUpDocumentListeners();
181181
}
182182

183-
if (tabKeyDetected && shiftKeyDetected) {
184-
if (activeElement !== null && activeElement === getFirstTabbableElement()) {
183+
if (tabKeyDetected && ! shiftKeyDetected) {
184+
if (activeElement !== null && activeElement === getLastTabbableElement()) {
185185
event.preventDefault();
186186

187-
focusLastTabbableElement();
187+
focusFirstTabbableElement();
188188
}
189-
} else if (tabKeyDetected && ! shiftKeyDetected) {
190-
if (activeElement !== null && activeElement === getLastTabbableElement()) {
189+
} else if (tabKeyDetected && shiftKeyDetected) {
190+
if (activeElement !== null && activeElement === getFirstTabbableElement()) {
191191
event.preventDefault();
192192

193-
focusFirstTabbableElement();
193+
focusLastTabbableElement();
194194
}
195195
}
196196
});

0 commit comments

Comments
 (0)