-
Notifications
You must be signed in to change notification settings - Fork 615
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(Table): respect sort prop updates from parent component #1208
Merged
benjamincanac
merged 3 commits into
nuxt:dev
from
ivantopo:fix/table-sort-from-parent-component
Jan 9, 2024
Merged
fix(Table): respect sort prop updates from parent component #1208
benjamincanac
merged 3 commits into
nuxt:dev
from
ivantopo:fix/table-sort-from-parent-component
Jan 9, 2024
Conversation
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
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
benjamincanac
changed the title
fix(table): respect sort prop updates from parent component
fix(Table): respect sort prop updates from parent component
Jan 8, 2024
@@ -158,7 +159,7 @@ export default defineComponent({ | |||
|
|||
const columns = computed(() => props.columns ?? Object.keys(props.rows[0] ?? {}).map((key) => ({ key, label: upperFirst(key), sortable: false, class: undefined }))) | |||
|
|||
const sort = ref(defu({}, props.sort, { column: null, direction: 'asc' })) | |||
const sort = useVModel(props, 'sort', emit, { passive: true, defaultValue: defu({}, props.sort, { column: null, direction: 'asc' }) }) |
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.
Is deep
option not necessary here?
benjamincanac
approved these changes
Jan 9, 2024
Thanks π |
hey @benjamincanac, thanks for the review, the fixes, and the quick merging! I'll make sure to lint before next PR π |
No worries! π |
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.
π Linked issue
Fixes #946
β Type of change
π Description
As described on #946 and demonstrated on this example, any changes to the
sort
prop in a parent component are not reflected on the table, except for defining the default sorting when the table component is initialized. I was made aware of reactive sorting on the table component but it only takes care of emitting update events that the parent can listen to, without bringing any changes to thesort
prop on the parent to the current state of the table.This change uses
useVModel
withpassive: true
so that if the parent provides thesort
property then the table will use it, otherwise using an internal sort state as it was doing before. This fixes #946.π Checklist