Skip to content

[fix] 질문 제목 반응형 레이아웃 변경#688

Merged
lepitaaar merged 1 commit intodevelop-fefrom
fix/add-responsive-layout-title
Aug 23, 2025
Merged

[fix] 질문 제목 반응형 레이아웃 변경#688
lepitaaar merged 1 commit intodevelop-fefrom
fix/add-responsive-layout-title

Conversation

@lepitaaar
Copy link
Contributor

@lepitaaar lepitaaar commented Aug 22, 2025

#️⃣연관된 이슈

#687

📝작업 내용

  useLayoutEffect(() => {
    if (textAreaRef.current) {
      const el = textAreaRef.current;
      if (mode === 'answer') {
        el.style.width = el.value.length + "ch";
      }
      el.style.height = '0px';
      el.style.height = `${el.scrollHeight}px`;
    }
  }, [title]);

지원서 입력모드에서 textarea의 너비를 ch로 텍스트 크기에 맞게 변경되도록 합니다.

QuestionTitleTextContainer은 flex:1;
QuestionTitleText는 width: 100%을 이용해 지원서 제작시에 너비가 부모에 맞게 설정되도록 변경하여 모든브라우저에서 표시되는 화면을 통일했습니다.

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

Summary by CodeRabbit

  • 신기능
    • 질문 제목 입력창이 내용에 맞춰 자동으로 크기(높이, 일부 모드에서 너비 포함)가 조절되어 가독성과 사용성이 향상되었습니다.
  • 스타일
    • 제목 영역의 레이아웃을 개선하여 컨테이너가 공간을 적절히 채우고, 입력창이 가로폭을 안정적으로 활용하도록 조정했습니다.

@lepitaaar lepitaaar self-assigned this Aug 22, 2025
@lepitaaar lepitaaar added 🎨 Design 마크업 & 스타일링 💻 FE Frontend 🛠Fix 기능이 의도한 대로 동작하지 않는 버그를 수정 labels Aug 22, 2025
@vercel
Copy link

vercel bot commented Aug 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
moadong Ready Ready Preview Comment Aug 22, 2025 0:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 22, 2025

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

QuestionTitle 컴포넌트에 textarea 자동 리사이즈 로직을 추가하고, 관련 스타일을 조정했습니다. useLayoutEffect와 ref를 도입해 제목 변경 시 높이를 scrollHeight에 맞추고, answer 모드에서는 내용 길이에 따라 너비를 설정합니다. 스타일로 flex와 width 속성을 보강했습니다.

Changes

Cohort / File(s) Summary
QuestionTitle 컴포넌트
frontend/src/components/application/QuestionTitle/QuestionTitle.tsx, frontend/src/components/application/QuestionTitle/QuestionTitle.styles.ts
TSX: useLayoutEffect/useRef 추가, textarea ref 바인딩, auto-resize(높이=scrollHeight) 및 answer 모드 시 너비 조정, rows={1} 설정. 스타일: 컨테이너에 flex: 1, textarea에 width: 100% 추가. 공개 API 변경 없음.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant QT as QuestionTitle(Component)
  participant TA as textarea (DOM)
  participant BL as Browser Layout

  U->>QT: title 업데이트 (props/state)
  QT->>QT: useLayoutEffect(title)
  QT->>TA: height = 0px
  QT->>TA: if (mode==='answer') set width by content length
  QT->>TA: height = TA.scrollHeight
  TA->>BL: 레이아웃 재계산
  BL-->>U: 리사이즈된 textarea 표시
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • Zepelown
  • seongwon030
  • oesnuj
  • suhyun113

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/add-responsive-layout-title

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (4)
frontend/src/components/application/QuestionTitle/QuestionTitle.styles.ts (2)

33-33: flex: 1은 flex-basis: 0%라서 width: fit-content 의미를 잃습니다 — flex: auto(=1 1 auto)로 변경 권장

현재 설정은 콘텐츠 고유 너비를 무시하고 가용 공간을 균등 분배하려는 동작을 유도합니다. 콘텐츠 기반으로 계산하되 필요 시 확장하려면 flex-basis가 auto여야 합니다. 또한 flex 컨텍스트에서 줄바꿈/축소 이슈를 줄이기 위해 min-width: 0 추가를 권장합니다.

-  flex: 1;
+  /* 콘텐츠 기반 계산 유지 + 필요 시 확장 */
+  flex: 1 1 auto;
+  /* 긴 단어/줄에서 축소 가능하도록 */
+  min-width: 0;

39-39: answer 모드에서 inline width=Nch가 부모를 넘을 수 있음 — max-width: 100%로 캡 추가

JS에서 el.style.width를 "Nch"로 설정할 때 부모 max-width를 초과하면 수평 오버플로우가 발생할 수 있습니다. CSS에 max-width: 100%를 추가해 상한을 보장하세요. (inline width는 max-width에 의해 제어됩니다.)

   min-width: 100px;
-  width: 100%;
+  width: 100%;
+  max-width: 100%;
frontend/src/components/application/QuestionTitle/QuestionTitle.tsx (2)

24-34: mode 변경 시 재계산 누락 및 answer→builder 전환 시 inline width 잔존 가능

의존성 배열이 [title]만 포함해 mode 전환 시(예: builder↔answer) 재계산이 누락됩니다. 또한 builder로 돌아올 때 JS로 설정된 inline width가 남아 width: 100% 스타일이 적용되지 않을 수 있습니다. deps에 mode를 포함하고, answer 이외에는 width를 초기화해 주세요. 다중 줄 제목에서는 전체 길이 대신 “가장 긴 줄” 기준으로 Nch 계산하는 편이 덜 과대/과소추정됩니다.

-  useLayoutEffect(() => {
-    if (textAreaRef.current) {
-      const el = textAreaRef.current;
-      if (mode === 'answer') {
-        el.style.width = el.value.length + "ch";
-      }
-      el.style.height = '0px';
-      el.style.height = `${el.scrollHeight}px`;
-    }
-  }, [title]);
+  useLayoutEffect(() => {
+    const el = textAreaRef.current;
+    if (!el) return;
+    if (mode === 'answer') {
+      // 가장 긴 라인 기준으로 너비 산정 (개행 고려)
+      const longestLineCh = el.value
+        .split('\n')
+        .reduce((max, line) => Math.max(max, line.length), 0);
+      el.style.width = `${longestLineCh}ch`;
+    } else {
+      // builder 모드 복귀 시 inline width 제거 → CSS width: 100% 적용
+      el.style.width = '';
+    }
+    // 높이 재계산
+    el.style.height = '0px';
+    el.style.height = `${el.scrollHeight}px`;
+  }, [title, mode]);

추가 메모(선택): 폰트/스크립트(CJK 등)에서 ch 단위는 실제 글리프 폭과 차이가 날 수 있습니다. 필요하면 Canvas 측정이나 ResizeObserver를 도입해 정확도를 높일 수 있습니다.


42-43: rows={1}와 auto-height 결합 LGTM — 접근성 보완 제안

구현은 적절합니다. 접근성 표시를 위해 required 표시가 있는 경우 aria-required를 함께 노출하는 것을 권장합니다.

         <Styled.QuestionTitleText
           ref={textAreaRef}
           rows={1}
+          aria-required={mode === 'answer' && !!required}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d8b3de5 and a1f05da.

📒 Files selected for processing (2)
  • frontend/src/components/application/QuestionTitle/QuestionTitle.styles.ts (1 hunks)
  • frontend/src/components/application/QuestionTitle/QuestionTitle.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

frontend/**/*.{ts,tsx}: Replace magic numbers with named constants for clarity.
Replace complex or nested ternary operators with if/else statements or IIFEs for readability.
Assign complex boolean conditions to named variables.
Use consistent return types for similar functions and hooks.
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle).
Use unique, descriptive names for custom wrappers and functions to avoid ambiguity.
Define constants near related logic or ensure names link them clearly.

Files:

  • frontend/src/components/application/QuestionTitle/QuestionTitle.styles.ts
  • frontend/src/components/application/QuestionTitle/QuestionTitle.tsx
frontend/**/*.tsx

📄 CodeRabbit inference engine (frontend/.cursorrules)

frontend/**/*.tsx: Abstract complex logic/interactions into dedicated components or higher-order components (HOCs).
Separate significantly different conditional UI/logic into distinct components.
Colocate simple, localized logic or use inline definitions to reduce context switching.
Choose field-level or form-level cohesion based on form requirements.
Break down broad state management into smaller, focused hooks or contexts.
Use component composition instead of props drilling.

Files:

  • frontend/src/components/application/QuestionTitle/QuestionTitle.tsx
🔇 Additional comments (2)
frontend/src/components/application/QuestionTitle/QuestionTitle.tsx (2)

4-4: useLayoutEffect 도입 적절

페인트 전에 치수 계산을 수행하여 레이아웃 점프를 줄이는 선택이 적절합니다.


22-22: ref 도입 적절

DOM 치수 계산을 위한 textAreaRef 추가는 타당합니다.

Copy link
Member

@seongwon030 seongwon030 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~ 지금 vercel 로 보니까 개발 서버가 아직 허용이 안되어 있는 것 같네요!

@lepitaaar lepitaaar merged commit 9f8a7a4 into develop-fe Aug 23, 2025
5 checks passed
@lepitaaar lepitaaar deleted the fix/add-responsive-layout-title branch September 20, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎨 Design 마크업 & 스타일링 💻 FE Frontend 🛠Fix 기능이 의도한 대로 동작하지 않는 버그를 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments