Skip to content

Commit 2f0a94d

Browse files
committed
検索画面
空文字の場合は検索しない 記事が0個の時の表示を記述
1 parent 0fdac44 commit 2f0a94d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pages/search/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ const SearchPage: NextPage<Props> = (props) => {
4444
<Layout {...props}>
4545
<Search isShowText={false} />
4646
{data === undefined ? (
47-
<div v-if="loading === true" className={styles.loader}>
47+
<div className={styles.loader}>
4848
<img className={styles.loadingIcon} src="/images/icon_loading.svg" alt="検索中..." />
4949
</div>
50+
) : data.contents.length === 0 ? (
51+
<div className={styles.loader}>記事がありません</div>
5052
) : (
5153
<BlogList contents={data.contents} />
5254
)}

src/components/Search/Search.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const Container: React.VFC<ContainerProps> = (props) => {
2828

2929
const router = useRouter()
3030
const handleKeyPress: Props['onKeyPress'] = (event) => {
31+
if (value === '') {
32+
return
33+
}
3134
if (event.key === 'Enter') {
3235
router.push({
3336
pathname: pagesPath.search.$url().pathname,

0 commit comments

Comments
 (0)