Skip to content

Commit b583f68

Browse files
committed
Fix implementation bug in search bar related to handling escape keypress
1 parent e477ea3 commit b583f68

5 files changed

Lines changed: 28 additions & 10 deletions

File tree

_TODO.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,3 @@ We have generated detailed outlines for each of the MDX proposed articles we hav
160160
Act as a principal software engineer. Your goal is to write a detailed technical article based on the provided outline. Context: The target audience is Senior DevOps and infrastructure Engineers. The tone should be authoritative, professional, and concise, avoiding fluff or filler words. Think step-by-step before writing to improve the accuracy of technical explanations. Use a friendly first-person voice. Anything that reads like generic marketing copy is not what we want but we still want the effect of being "real" and approachable - try not to sound like technical documentation. We want to show empathy for our readers.
161161

162162
Let's work through each article section by section based on the H2 headers in the outline. If the section looks good as-is, I'll just type "ok" so you know to continue to the next section.
163-
164-
## Build Errors
165-
166-
22:50:48 [WARN] [glob-loader] The base directory "/home/kevin/Repos/WebstackBuilders/CorporateWebsite/astro.webstackbuilders.com/src/content/about/" does not exist.

src/components/Footer/footer.module.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@
2525
stroke: var(--color-content);
2626
}
2727

28+
.footerSocialLink {
29+
text-decoration: none;
30+
}
31+
32+
.footerSocialPlatform {
33+
text-decoration-color: var(--color-primary);
34+
text-decoration-line: underline;
35+
text-decoration-style: dotted;
36+
text-underline-offset: 4px;
37+
}
38+
39+
.footerSocialLink:hover .footerSocialPlatform,
40+
.footerSocialLink:focus-visible .footerSocialPlatform {
41+
text-decoration-color: var(--color-secondary);
42+
}
43+
2844
.footerSocialLink:hover :global([data-icon]),
2945
.footerSocialLink:focus-visible :global([data-icon]) {
3046
fill: var(--color-secondary);
@@ -211,6 +227,7 @@
211227

212228
.footerHireMeAnchor {
213229
margin-top: 0.5rem;
230+
text-decoration: none;
214231
}
215232
}
216233

src/components/Footer/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const year = new Date().getFullYear()
7474
id="page-footer__hire-me-anchor"
7575
class:list={[
7676
styles.footerHireMeAnchor,
77-
"hidden uppercase hover:text-secondary hover:decoration-secondary focus:text-secondary focus:decoration-secondary after:ml-1 after:content-['>']",
77+
"hidden uppercase hover:text-secondary focus:text-secondary after:ml-1 after:content-['>']",
7878
]}
7979
aria-label="Available Now. Hire Me"
8080
>
@@ -96,7 +96,7 @@ const year = new Date().getFullYear()
9696
rel="me"
9797
class:list={[
9898
styles.footerSocialLink,
99-
'group flex flex-col hover:text-secondary hover:decoration-secondary focus:text-secondary focus:decoration-secondary',
99+
'group flex flex-col hover:text-secondary focus:text-secondary',
100100
]}
101101
>
102102
<span class:list={[styles.footerSocialHeaderRow, 'flex items-baseline']}>

src/components/Search/SearchBar/client/__tests__/index.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import SearchBarHeaderFixture from '@components/Search/SearchBar/client/__fixtur
55
import type { SearchBarElement as SearchBarElementInstance } from '../index'
66
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
77
import { executeRender } from '@test/unit/helpers/litRuntime'
8+
import { __resetHeaderSearchForTests } from '@components/scripts/store/search'
89

910
type SearchBarModule = WebComponentModule<SearchBarElementInstance>
1011

@@ -57,6 +58,8 @@ describe('SearchBar web component', () => {
5758
container = await AstroContainer.create()
5859
searchQueryMock.mockReset()
5960

61+
__resetHeaderSearchForTests()
62+
6063
delete (globalThis as unknown as Record<string, unknown>)['SpeechRecognition']
6164
delete (globalThis as unknown as Record<string, unknown>)['webkitSpeechRecognition']
6265
})
@@ -173,7 +176,7 @@ describe('SearchBar web component', () => {
173176
expect(toggleBtn.hasAttribute('hidden')).toBe(true)
174177
expect(clearBtn.hasAttribute('hidden')).toBe(false)
175178

176-
input.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
179+
input.dispatchEvent(new window.KeyboardEvent('keyup', { key: 'Escape', bubbles: true }))
177180
await flushMicrotasks()
178181

179182
expect(toggleBtn.getAttribute('aria-expanded')).toBe('false')

src/components/Search/SearchBar/client/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,19 +434,21 @@ export class SearchBarElement extends LitElement {
434434
return
435435
}
436436

437-
if (!(event instanceof KeyboardEvent)) {
437+
if (!(typeof (event as KeyboardEvent).key === 'string')) {
438438
return
439439
}
440440

441-
if (event.key !== 'Escape') {
441+
const keyboardEvent = event as KeyboardEvent
442+
443+
if (keyboardEvent.key !== 'Escape') {
442444
return
443445
}
444446

445447
if (!this.isExpanded) {
446448
return
447449
}
448450

449-
event.preventDefault()
451+
keyboardEvent.preventDefault()
450452
this.collapse({ restoreFocus: true })
451453
}
452454

0 commit comments

Comments
 (0)