fix: Sortable 드래그 좌표를 실제 스크롤 컨테이너 기준으로 계산#469
Open
205sla wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes incorrect drop index calculation when dragging sortable lists while the list is scrolled, by ensuring react-sortable-hoc computes drag coordinates relative to the actual scroll container (.rcs-inner-container from react-custom-scroll) instead of the inner list element.
Changes:
- Store the sortable root element via a
refcallback. - Provide
getContainertoreact-sortable-hocto return the nearest.rcs-inner-container(with fallback to root). - Delay container resolution until the root ref is available (via a Promise-based resolver).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+80
to
+83
| getSortContainer = () => { | ||
| const container = | ||
| (this.sortableRoot && this.sortableRoot.closest('.rcs-inner-container')) || | ||
| this.sortableRoot; |
Author
There was a problem hiding this comment.
210bb38에서 반영했습니다. Element.closest()를 직접 쓰던 코드를 제거하고 레거시 브라우저를 위해 matches/msMatchesSelector 기반의 간단한 부모 순회 폴백을 추가했습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
드래그를 시작한 뒤 목록을 스크롤할 때 정렬 드롭 좌표가 어긋나는 문제를 수정했습니다.
원인
SortableList가react-sortable-hoc에getContainer를 넘기지 않아 내부 목록 요소를 스크롤 컨테이너로 삼았습니다. 하지만 실제로 스크롤되는 요소는react-custom-scroll이 만든 상위.rcs-inner-container입니다. 이 요소의scrollTop변화가 드래그 좌표 계산에 반영되지 않아newIndex가 포인터 아래 항목과 달라졌습니다.변경 사항
getContainer로 가장 가까운.rcs-inner-container를 반환합니다.SortableList에getContainer를 전달합니다.react-sortable-hoc@0.8.4는getContainer결과를Promise.resolve()로 처리하므로 비동기 컨테이너를 지원합니다.검증
npm run build:prod: 기존 번들 크기 경고만 발생하며 통과.scrollTop610 → 915 / 포인터 인덱스·emit된newIndex·모델 인덱스·DOM 인덱스 17 일치.scrollTop915 → 610 / 포인터 인덱스·emit된newIndex·모델 인덱스·DOM 인덱스 12 일치.참고
모양·소리·장면 목록은 이
Sortable컴포넌트를 공유합니다.장면 목록의 가로 방향 드래그 중 스크롤은 가로 휠 장치가 없어 수동으로 테스트하지 못했지만 일반적인 장면 정렬은 브라우저 자동화로 확인했습니다.
동작 확인 영상
https://youtu.be/p_tc8PTfUHc