You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Status**: Completed (User Story 1) / Draft (User Story 2)
5
+
**Status**: Completed (User Story 1 & 3) / Draft (User Story 2)
6
6
**Input**: User description: "fix line number scrolling"
7
7
8
8
## User Scenarios & Testing _(mandatory)_
@@ -49,10 +49,37 @@ As a user viewing diffs on different screen sizes, I want the line numbers to di
49
49
50
50
---
51
51
52
+
### User Story 3 - Horizontal Scrollbar Detection (Priority: P1) β **COMPLETED**
53
+
54
+
As a user viewing diffs with long lines that cause horizontal scrollbars, I want the line numbers to have extra bottom padding when horizontal scrollbars appear, so the last line number remains visible and not obscured by the scrollbar.
55
+
56
+
**Why this priority**: This addresses a visual usability issue where horizontal scrollbars can cover the last line number, making it difficult to reference the final line in the diff.
57
+
58
+
**Independent Test**: Can be fully tested by creating content that triggers horizontal scrolling and verifying the last line number has appropriate padding.
59
+
60
+
**Acceptance Scenarios**:
61
+
62
+
1.**Given** a diff with long lines that trigger horizontal scrolling, **When** the scrollbar appears, **Then** the line number gutter adds 2rem bottom padding plus scrollbar height
63
+
2.**Given** a diff with short lines that don't trigger horizontal scrolling, **When** rendered, **Then** the line number gutter uses normal padding without extra space
64
+
3.**Given** content changes that add/remove horizontal scrolling, **When** the scrollbar state changes, **Then** the padding updates dynamically
65
+
66
+
**Implementation Notes**:
67
+
68
+
- Added horizontal scrollbar detection using `scrollWidth > clientWidth` comparison
69
+
- Implemented dynamic padding with `pb-[calc(2rem+var(--scrollbar-size,0px))]` CSS class
70
+
- Added `useState` to track scrollbar presence in both `TextInput` and `LineNumberGutter` components
71
+
- Used `useEffect` with `setTimeout` to avoid React setState warnings
72
+
- Enhanced both components to detect scrollbars and apply padding automatically
73
+
- Maintained 100% test coverage with comprehensive test cases
74
+
- Used CSS custom properties for scrollbar size customization
75
+
76
+
---
77
+
52
78
### Edge Cases
53
79
54
80
- β **SOLVED**: What happens when line numbers have different digit counts (e.g., line 9 vs line 1000)? β Dynamic width calculation (2-3 digits)
55
81
- β **SOLVED**: How does system handle very long lines that exceed viewport width? β Horizontal scrolling with `whitespace-pre` prevents wrapping
82
+
- β **SOLVED**: What happens when horizontal scrollbars appear and cover the last line number? β Dynamic bottom padding detection with 2rem + scrollbar height
56
83
- What happens when the diff content is shorter than the viewport height? β Line numbers still render correctly
57
84
- What happens when the diff content is shorter than the viewport height? β Current behavior preserved
58
85
- β **SOLVED**: What happens when text is pasted creating very long lines? β Horizontal scrolling maintains alignment
@@ -80,14 +107,19 @@ As a user viewing diffs on different screen sizes, I want the line numbers to di
80
107
-**FR-005**: System MUST ensure line numbers remain readable and accessible
81
108
-**FR-006**: System MUST maintain proper spacing between line numbers and content
82
109
-**FR-007**: System MUST preserve native textarea functionality (selection, copy, accessibility) while achieving synchronization
110
+
-**FR-008**: System MUST detect horizontal scrollbars and add appropriate bottom padding to line number gutters
111
+
-**FR-009**: System MUST dynamically adjust padding when horizontal scrollbar state changes
112
+
-**FR-010**: System MUST use 2rem bottom padding plus scrollbar height when horizontal scrollbar is detected
83
113
84
114
### Key Entities _(include if feature involves data)_
85
115
86
-
-**Line Number Gutter**: The auto-sizing column displaying line numbers in a separate scroll container, using monospace font with right-alignment, minimum 2-digit width growing to maximum 3-digit width
116
+
-**Line Number Gutter**: The auto-sizing column displaying line numbers in a separate scroll container, using monospace font with right-alignment, minimum 2-digit width growing to maximum 3-digit width, with dynamic bottom padding for horizontal scrollbars
87
117
-**Diff Content Area**: The textarea containing diff text with synchronized scrolling
88
118
-**Scroll Container**: Linked containers managing coordinated scroll behavior between gutter and content
89
119
-**Viewport**: The visible area of the diff viewer
90
120
-**Scroll Event Coordinator**: JavaScript mechanism synchronizing scroll positions between containers
121
+
-**Horizontal Scrollbar Detector**: JavaScript logic that compares `scrollWidth` vs `clientWidth` to detect scrollbar presence
122
+
-**Dynamic Padding Calculator**: CSS-based system using `calc(2rem+var(--scrollbar-size,0px))` for appropriate spacing
91
123
92
124
## Success Criteria _(mandatory)_
93
125
@@ -101,6 +133,14 @@ As a user viewing diffs on different screen sizes, I want the line numbers to di
101
133
-**SC-004**: Line number display works correctly across viewport widths from 320px to 1920px β
102
134
-**SC-005**: No horizontal scrollbar appears for line number gutter under any circumstances β
103
135
136
+
**User Story 3 - Horizontal Scrollbar Detection** β **COMPLETED**
137
+
138
+
-**SC-010**: Horizontal scrollbars are detected automatically using scrollWidth vs clientWidth comparison β
139
+
-**SC-011**: Line number gutter adds 2rem bottom padding when horizontal scrollbar is present β
140
+
-**SC-012**: Padding updates dynamically when scrollbar state changes β
141
+
-**SC-013**: Last line number remains visible and not obscured by horizontal scrollbar β
142
+
-**SC-014**: Normal padding is maintained when no horizontal scrollbar is present β
143
+
104
144
**User Story 2 - Responsive Line Number Display** π **IN PROGRESS**
105
145
106
146
-**SC-006**: Line numbers adapt to different viewport sizes without breaking layout
@@ -113,8 +153,10 @@ As a user viewing diffs on different screen sizes, I want the line numbers to di
0 commit comments