-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cannot edit after sort #2001
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a098438
test: add test
jajugoguma c9dad0c
feat: forced make observable
jajugoguma fd79960
fix: make viewport data and previously observable data to observable
jajugoguma ae3f0e5
fix: correct typo
jajugoguma 754e60c
chore: change params of makeObservable to object
jajugoguma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,23 @@ import { Data, ViewRow, Row } from '@t/store/data'; | |
import { SortingType } from '@t/store/column'; | ||
import { SortStateResetOption } from '@t/options'; | ||
import { findPropIndex, isUndefined } from '../helper/common'; | ||
import { notify, unobservable } from '../helper/observable'; | ||
import { isObservable, notify } from '../helper/observable'; | ||
import { sortRawData } from '../helper/sort'; | ||
import { getEventBus } from '../event/eventBus'; | ||
import { updateRowNumber, setCheckedAllRows } from './data'; | ||
import { updateRowNumber, setCheckedAllRows, makeObservable } from './data'; | ||
import { isSortable, isInitialSortState, isScrollPagination, isSorted } from '../query/data'; | ||
import { isComplexHeader } from '../query/column'; | ||
import { isCancelSort, createSortEvent, EventType, EventParams } from '../query/sort'; | ||
import { updateRowSpan } from './rowSpan'; | ||
|
||
function createSoretedViewData(rawData: Row[]) { | ||
function createSortedViewData(rawData: Row[]) { | ||
return rawData.map( | ||
({ rowKey, sortKey, uniqueKey }) => ({ rowKey, sortKey, uniqueKey } as ViewRow) | ||
); | ||
} | ||
|
||
function sortData(store: Store) { | ||
const { data, column } = store; | ||
const { data, column, viewport } = store; | ||
const { sortState, rawData, viewData, pageRowRange } = data; | ||
const { columns } = sortState; | ||
const sortedColumns = columns.map((sortedColumn) => ({ | ||
|
@@ -33,17 +33,29 @@ function sortData(store: Store) { | |
|
||
targetRawData.sort(sortRawData(sortedColumns)); | ||
|
||
const targetViewData = createSoretedViewData(targetRawData); | ||
const targetViewData = createSortedViewData(targetRawData); | ||
|
||
data.rawData = targetRawData.concat(rawData.slice(pageRowRange[1])); | ||
data.viewData = targetViewData.concat(viewData.slice(pageRowRange[1])); | ||
} else { | ||
rawData.sort(sortRawData(sortedColumns)); | ||
data.viewData = createSoretedViewData(rawData); | ||
data.viewData = createSortedViewData(rawData); | ||
} | ||
|
||
data.rawData.forEach((rawRow) => { | ||
unobservable(rawRow); | ||
const rowKeysInViewport = viewport.rows.map(({ rowKey }) => rowKey); | ||
|
||
data.rawData.forEach((rawRow, index) => { | ||
const { rowKey } = rawRow; | ||
|
||
if (isObservable(rawRow) || rowKeysInViewport.includes(rowKey)) { | ||
makeObservable({ | ||
store, | ||
rowIndex: index, | ||
silent: false, | ||
lazyObservable: false, | ||
forced: true, | ||
}); | ||
} | ||
}); | ||
Comment on lines
+47
to
59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rawRow가 반응형 데이터 일 때 대응하는 viewRow가 올바른 속성을 갖도록 하기 위해 이와 같이 수정했습니다. 정렬 후 기존에 반응형 데이터였던 데이터와 새롭게 뷰포트에 나타나는 데이터는 반응형 데이터야 합니다. |
||
} | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존에 반응형 데이터 였던 row를 다시 반응형 데이터로 만들기 위해
forced
인자를 추가했습니다.