Skip to content

Commit 5d95ad6

Browse files
committed
fix: text overflow on seach modal
1 parent d32c402 commit 5d95ad6

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/components/Header/Search/Search.module.css

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
top: 65px;
77
left: 0;
88
right: 0;
9-
height: 100vh;
9+
height: calc(100vh - 65px);
1010
padding-top: 60px;
1111
border-radius: 0;
1212
}
1313

1414
#searchModal.large {
1515
top: 0;
1616
height: fit-content;
17-
max-height: 80vh;
1817
background: #fff;
1918
position: absolute;
2019
border-radius: 24px;
@@ -24,7 +23,7 @@
2423

2524
.resultsWrapper {
2625
padding: 20px 20px 1rem;
27-
overflow: overlay;
26+
height: calc(100% - 50px);
2827
}
2928

3029
.searchInput {
@@ -129,11 +128,6 @@
129128
box-sizing: content-box;
130129
}
131130

132-
.hitWrapper {
133-
max-height: 40vh;
134-
overflow: overlay;
135-
}
136-
137131
.hitWrapper ol {
138132
list-style: none;
139133
}
@@ -147,6 +141,9 @@
147141
.queryResults {
148142
display: grid;
149143
grid-template-columns: 1fr;
144+
grid-auto-rows: max-content;
145+
height: 100%;
146+
overflow-y: auto;
150147
}
151148

152149
.queryResults h6 {
@@ -224,8 +221,8 @@
224221
}
225222

226223
.hitWrapper {
227-
max-height: calc(80vh - 100px);
228-
overflow: auto;
224+
max-height: calc(80vh - 150px);
225+
overflow-y: auto;
229226
}
230227

231228
.hitList li {
@@ -259,4 +256,9 @@
259256
.resultsWrapper * {
260257
padding-left: 0 !important;
261258
}
259+
260+
.queryResults.large {
261+
max-height: calc(80vh - 48px);
262+
height: max-content;
263+
}
262264
}

src/components/Header/Search/SearchModal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ const recommendedArticles = [
2929
},
3030
]
3131

32-
function EmptyQueryBoundary({ children, fallback }) {
32+
function EmptyQueryBoundary({ children, size, fallback }) {
3333
const { indexUiState } = useInstantSearch()
3434

3535
const recentArticles = JSON.parse(localStorage.getItem("recentArticles") || "[]")
3636

37+
console.log(indexUiState, "indexUiState")
3738
if (!indexUiState.query) {
3839
return (
39-
<div className={styles.queryResults}>
40+
<div className={clsx(styles.queryResults, styles[size])}>
4041
<div>
4142
<h6 style={{ paddingLeft: "var(--space-2x)", marginBottom: "1rem" }}>Recommended articles</h6>
4243
<div className={styles.hitWrapper}>
@@ -108,6 +109,7 @@ function NoResultsBoundary({ children }) {
108109
function CustomHits({ title, hitClassName, ...props }: UseHitsProps & { title: string; hitClassName?: string }) {
109110
const { hits, results } = useHits(props)
110111

112+
console.log(hits, "hits")
111113
if (hits.length === 0) return null
112114
return (
113115
<div>
@@ -150,9 +152,9 @@ export function SearchModal({ size = "mini", isOpen, onClose }: { size: Size; is
150152
<InstantSearch indexName={getIndexName()} searchClient={searchClient}>
151153
<SearchInput size={size} onClose={onClose} />
152154
<div className={styles.resultsWrapper}>
153-
<EmptyQueryBoundary fallback={null}>
155+
<EmptyQueryBoundary fallback={null} size={size}>
154156
<NoResultsBoundary>
155-
<div className={styles.queryResults}>
157+
<div className={clsx(styles.queryResults, styles[size])}>
156158
<CustomHits
157159
title="Title Matches"
158160
escapeHTML={false}

0 commit comments

Comments
 (0)