-
Notifications
You must be signed in to change notification settings - Fork 687
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
[Accordion] Add "collapse all"/ "expand all" logic into AccordionContainer #11565
[Accordion] Add "collapse all"/ "expand all" logic into AccordionContainer #11565
Conversation
Build Artifacts
|
Thanks @AlexVelezLl ! This will need to be rebased once #11434 is merged and you might run into some minor conflicts I'll be happy to help resolve. |
@@ -185,57 +185,34 @@ | |||
</KGrid> | |||
|
|||
<AccordionContainer | |||
:items="quizForge.activeQuestions.value" | |||
@toggled="items => expandedQuestionIds = items" | |||
:items="quizForge.activeQuestions.value.map(i => ({ |
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.
I would suggest that we can make items
a generic array of objects that contains, for example, the id
attribute (instead of something specific like "question_id"), and that from this we have the criteria to know which items to choose expand when the "expand all" button is clicked.
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.
Excellent idea!
}; | ||
}, | ||
watch: { | ||
expandedItemIds() { | ||
this.$emit('toggled', this.expandedItemIds); |
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.
By handling the collapse all and expand all within the AccordionComponent, I think we can handle the functionality of the expandedItemIds within the component without having to expose the entire array, and just expose the isItemExpanded
method.
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.
Agreed 👍🏻
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.
Great work @AlexVelezLl thank you!
I tested it manually and it works as expected. Thanks for the additional clean-up and normalizing the component to use a generic id
property on the object passed in for the items that's excellent <3
@@ -185,57 +185,34 @@ | |||
</KGrid> | |||
|
|||
<AccordionContainer | |||
:items="quizForge.activeQuestions.value" | |||
@toggled="items => expandedQuestionIds = items" | |||
:items="quizForge.activeQuestions.value.map(i => ({ |
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.
Excellent idea!
}; | ||
}, | ||
watch: { | ||
expandedItemIds() { | ||
this.$emit('toggled', this.expandedItemIds); |
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.
Agreed 👍🏻
type: Array, | ||
required: true, | ||
function(value) { | ||
return value.every(item => typeof item === 'object' && 'id' in item); |
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.
TIL 🤯 'id' in { id: 1 }
=> true
So many times I've written Object.keys(theObj).includes(theKey)
and I could have just used in
Summary
Before
After
References
Closes #11547
Reviewer guidance
const quizForge = useQuizCreation(true);
hereTesting checklist
PR process
Reviewer checklist
yarn
andpip
)