Skip to content

fix: 검색 빈 화면 클릭 시 오류 해결#822

Merged
Sadturtleman merged 1 commit intodevelopfrom
fix/816
Mar 10, 2026
Merged

fix: 검색 빈 화면 클릭 시 오류 해결#822
Sadturtleman merged 1 commit intodevelopfrom
fix/816

Conversation

@Sadturtleman
Copy link
Contributor

@Sadturtleman Sadturtleman commented Mar 4, 2026

📌𝘐𝘴𝘴𝘶𝘦𝘴

📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯

  • 검색 빈 화면 클릭 시 오류 해결

📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵

KakaoTalk_Video_2026-03-04-22-45-43.mp4

💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴

확인해보니 클릭 시가 아닌 스크롤 시 api 요청을 보내어 생기는 오류인 걸로 확인했습니다. 검색어가 없을 경우 곧바로 return 하게 변경했습니다.

Summary by CodeRabbit

릴리스 노트

  • 버그 수정
    • 검색어가 비어있거나 공백일 때 검색 기능이 불필요한 작업을 수행하지 않도록 개선했습니다.

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

워크스루

검색 결과 업데이트 시 초기 조건을 개선했습니다. 검색 버튼 클릭이 아닌 경우, 검색어가 비어있거나 공백이거나 콘텐츠가 로드 불가능할 때 함수 실행을 차단합니다.

변경사항

코호트 / 파일 요약
검색 결과 로직 개선
app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt
updateSearchResult의 조건문을 수정하여 빈 검색어(null 또는 공백)에 대한 체크를 추가. 검색 버튼 클릭이 아닌 경우에만 빈 입력값을 처리.

예상 코드 리뷰 소요시간

🎯 1 (단순) | ⏱️ ~5 분

제안된 리뷰어

  • devfeijoa
  • m6z1

🐰 검색창 아래 텅 빈 곳,
클릭해도 묻지 마세요
조건문의 지혜로움이
쓸데없는 화면을 막으니
깔끔한 입력, 깔끔한 결과! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 검색 빈 화면에서 발생하는 오류 해결이라는 주요 변경 사항을 명확하게 설명하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 이슈 번호, 작업 설명, 스크린샷, 리뷰어를 위한 코멘트가 모두 포함되어 있습니다.
Linked Issues check ✅ Passed PR의 변경 사항은 이슈 #816의 요구 사항인 '검색어 없을 때 불필요한 동작 차단'을 충족하고 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경 사항이 검색 입력값 검증 강화라는 단일 목표에 초점을 맞추고 있으며, 범위를 벗어난 변경이 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/816

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt (1)

33-42: 수정 로직은 적절하나, query 변수 사용의 일관성을 고려해 주세요.

스크롤 시 빈 검색어에 대한 API 호출을 방지하는 수정은 올바릅니다. 다만 Line 34에서 trim()query 변수를 생성했지만, Line 42의 실제 API 호출에서는 원본 searchWord.value를 그대로 사용하고 있습니다.

이로 인해 검색 버튼 클릭 시 공백만 있는 검색어(예: " ")가 그대로 API에 전달될 수 있습니다. 일관성을 위해 API 호출에도 query 변수를 사용하는 것을 권장합니다.

♻️ 제안된 수정 사항
 fun updateSearchResult(isSearchButtonClick: Boolean) {
     val query = _searchWord.value?.trim() ?: ""
     // 검색어가 없고 스크롤을 하였을 경우 추가
     if ((query.isEmpty() || _uiState.value?.isLoadable == false) && !isSearchButtonClick) {
         return
     }
     viewModelScope.launch {
         _uiState.value = _uiState.value?.copy(loading = isSearchButtonClick)
         runCatching {
-            getNormalExploreResultUseCase(searchWord.value ?: "", isSearchButtonClick)
+            getNormalExploreResultUseCase(query, isSearchButtonClick)
         }.onSuccess { results ->
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt`
around lines 33 - 42, The method updateSearchResult creates a trimmed local
variable query but then calls getNormalExploreResultUseCase with
searchWord.value, which can pass untrimmed or whitespace-only input; change the
call inside viewModelScope.launch to use the trimmed query variable (query)
instead of searchWord.value so the same sanitized value is used for the API call
and for the empty-check logic in updateSearchResult.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt`:
- Around line 33-42: The method updateSearchResult creates a trimmed local
variable query but then calls getNormalExploreResultUseCase with
searchWord.value, which can pass untrimmed or whitespace-only input; change the
call inside viewModelScope.launch to use the trimmed query variable (query)
instead of searchWord.value so the same sanitized value is used for the API call
and for the empty-check logic in updateSearchResult.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 33319be9-ba85-43c3-9b91-2fa4116067b4

📥 Commits

Reviewing files that changed from the base of the PR and between a2248e1 and f759c08.

📒 Files selected for processing (1)
  • app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt

Copy link
Member

@m6z1 m6z1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다 👍 첫 PR이네요
환영해요 하루☺️

Copy link
Contributor

@devfeijoa devfeijoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

첫 PR이네요!! 수고하셨습니다 👍🏻
CI 실패했다고 뜨는데 그것만 확인 부탁드려요!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
feature/feed/src/main/java/com/into/websoso/feature/feed/FeedScreen.kt (1)

234-235: 디버그 로그가 남아있습니다.

Log.d("123123", tab.toString())는 디버깅 목적의 코드로 보입니다. 이 PR의 변경 사항은 아니지만, 프로덕션 코드에서 제거하는 것이 좋습니다.

🧹 디버그 로그 제거 제안
                     onClick = {
-                        Log.d("123123", tab.toString())
                         onTabClick(tab)
                     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@feature/feed/src/main/java/com/into/websoso/feature/feed/FeedScreen.kt`
around lines 234 - 235, Remove the remaining debug log call Log.d("123123",
tab.toString()) in FeedScreen (near the onTabClick(tab) invocation); either
delete the line or replace it with an appropriate production-level log/message
(e.g., use a meaningful tag and log level or telemetry) so only intentional,
contextual logging remains in the FeedScreen UI tab handling code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@feature/feed/src/main/java/com/into/websoso/feature/feed/FeedScreen.kt`:
- Around line 234-235: Remove the remaining debug log call Log.d("123123",
tab.toString()) in FeedScreen (near the onTabClick(tab) invocation); either
delete the line or replace it with an appropriate production-level log/message
(e.g., use a meaningful tag and log level or telemetry) so only intentional,
contextual logging remains in the FeedScreen UI tab handling code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 673285e1-176b-4612-9ce2-2be93e3d9e30

📥 Commits

Reviewing files that changed from the base of the PR and between 92d1a31 and b5f057a.

📒 Files selected for processing (1)
  • feature/feed/src/main/java/com/into/websoso/feature/feed/FeedScreen.kt

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt`:
- Around line 51-52: The current guard in NormalExploreViewModel that checks
_searchWord and _uiState to decide whether to return prevents pagination when
the input box is cleared; introduce and use a separate state (e.g.,
lastQueriedSearchWord: String?) to remember the search term used for the most
recent successful fetch, update lastQueriedSearchWord when a real API call is
made (inside the method that performs the fetch, referenced by
updateSearchResult / the ViewModel's fetch/search method), and change the
early-return condition to compare against lastQueriedSearchWord (or use it for
paging decisions) instead of _searchWord so clearing the input field does not
block subsequent page loads. Ensure clearing _searchWord does not reset
lastQueriedSearchWord and that pagination increments still reference
lastQueriedSearchWord for API calls.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e3e30ff-f8d3-44f2-ba8d-e65d194ee2a8

📥 Commits

Reviewing files that changed from the base of the PR and between b5f057a and 9fc551b.

📒 Files selected for processing (1)
  • app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt

Comment on lines +51 to 52
if ((_searchWord.value.isNullOrBlank() || _uiState.value?.isLoadable == false) && !isSearchButtonClick) {
return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

현재 입력값으로 페이징을 막으면 기존 검색 결과가 끊깁니다.

NormalExploreActivity.kt Line 63-68에서는 스크롤마다 updateSearchResult(false)를 호출하고, 이 ViewModel의 Line 90-93에서는 입력값만 비우고 결과 목록은 유지합니다. 그래서 한 번 검색한 뒤 입력창만 지우면 리스트는 남아 있는데 여기서 바로 return 되어 다음 페이지 로드가 영구히 막힙니다. 페이징 조건과 API 호출에는 “현재 입력값”이 아니라 “마지막으로 실제 조회에 사용한 검색어”를 별도 상태로 써야 합니다. 그렇지 않으면 빈 입력 방어는 되더라도 스크롤 페이징이 회귀합니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/into/websoso/ui/normalExplore/NormalExploreViewModel.kt`
around lines 51 - 52, The current guard in NormalExploreViewModel that checks
_searchWord and _uiState to decide whether to return prevents pagination when
the input box is cleared; introduce and use a separate state (e.g.,
lastQueriedSearchWord: String?) to remember the search term used for the most
recent successful fetch, update lastQueriedSearchWord when a real API call is
made (inside the method that performs the fetch, referenced by
updateSearchResult / the ViewModel's fetch/search method), and change the
early-return condition to compare against lastQueriedSearchWord (or use it for
paging decisions) instead of _searchWord so clearing the input field does not
block subsequent page loads. Ensure clearing _searchWord does not reset
lastQueriedSearchWord and that pagination increments still reference
lastQueriedSearchWord for API calls.

@devfeijoa
Copy link
Contributor

CI도 해결됐네요! 수고하셨습니다 👍

@Sadturtleman Sadturtleman merged commit 2c1dff4 into develop Mar 10, 2026
2 checks passed
@Sadturtleman Sadturtleman deleted the fix/816 branch March 10, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 [FIX] 버그를 수정합니다. 🧙마법사 하루

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 검색바 하단 클릭 시 문의하러가기 나옴

4 participants