enhancement (UI): add draggable resize handle for sidebar width adjustment#62
enhancement (UI): add draggable resize handle for sidebar width adjustment#62AmiiirCom wants to merge 12 commits into
Conversation
|
AI: Nice addition — clean, scoped to one file, and the mobile breakpoint disables the handle correctly. A few things to address before merging:
Minor: the new Happy to approve once 1–3 are fixed. |
…tion, dedupe media query
Merge dev into master
|
I tried to fix them. |
|
Hi again
|
fix(sidebar): add default width, clamp saved value, fix touch scrolling
|
Thanks for the detailed review. I've gone through each point and made the necessary fixes. Here's the breakdown: ✅ 1 – Default width brokenFixed. Added ❌ 2 – RTL drag direction invertedNot applied (intentional). In this app, the sidebar is physically on the left side in both RTL (Persian) and LTR layouts. The resize handle is always on the left edge of the sidebar. Flipping the delta based on ✅ 3 – Global non‑passive touchmove listenerFixed. Refactored touch dragging: ⏸️ 4 –
|
| if (w < 280) w = 280; | ||
| if (w > maxW) w = maxW; | ||
| sidebar.style.width = w + 'px'; | ||
| localStorage.setItem('thefeed_sidebar_width', w); |
There was a problem hiding this comment.
This write is redundant on every page load. Only write back if the value actually changed
| document.addEventListener('touchmove', onTouchMove, { passive: false }); | ||
| document.addEventListener('touchend', onTouchEnd); | ||
| }); | ||
| document.addEventListener('touchmove', function(e) { |
There was a problem hiding this comment.
This anonymous touchmove listener duplicates onTouchMove which is already registered inside touchstart. Unlike onTouchMove, this anonymous handler is never removed, it lives on the document forever. Every touch on the page fires it for the lifetime of the app. Remove lines entirely; onTouchMove already handles this.
| sidebar.style.width = newWidth + 'px'; | ||
| e.preventDefault(); | ||
| }, { passive: false }); | ||
| document.addEventListener('touchend', function() { |
There was a problem hiding this comment.
Same issue as above, this anonymous touchend handler duplicates onTouchEnd and is never cleaned up. Remove lines onTouchEnd covers it.
| if (!isDragging) return; | ||
| e.preventDefault(); | ||
| var newWidth = startWidth + (e.clientX - startX); | ||
| var maxW = window.innerWidth * 0.7; |
There was a problem hiding this comment.
window.innerWidth * 0.7 is calculated in 5+ separate places (load, save, mouseMove, touchMove, resize). Extract to a getMaxWidth() helper to make future changes to the cap easier.
| right: 0; | ||
| bottom: 0; | ||
| width: 100%; | ||
| width: 100% !important; |
There was a problem hiding this comment.
The !important here is fighting the inline style set by JS.
Cleaner fix: skip calling loadSidebarWidth() on mobile(e.g. guard with if (window.innerWidth <= 768) return;), then no inline style gets set and !important isn't needed
sepehr-alipour
left a comment
There was a problem hiding this comment.
The duplicate touch listeners are the only required fix before merge. The rest are polish.
|
any update!? |
Summary
Adds a draggable resize handle to the sidebar, allowing users to adjust its width dynamically. Improves UI flexibility and user control over layout space.