Fix accordion component calculations and header classes #262
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.
This is a fix for #238
When accordion panels are rendered dynamically the order calculations won't work properly because the actual DOM render and FwbAccordionPanel.vue onMounted function order are reversed. So the last rendered element has the order 0. This happens when the key attribute is unique each time. For this reason, I have updated the order calculation to check the actual DOM index. I have explained this in detail below with screenshots.
I have added onUnmounted to delete panel references that are removed.
In the composable files, the panel count calculation is wrong because it checks the keys of the 'panel' object. It always has 3 props: id, isVisible, and order. So in the calculation, the panel count is always 3. I have updated this to check the keys of the 'panels' object.
Lastly, I have updated some classes to match flush accordion styles.
Accordion Panel Render Issue
To test this, I have added an input as the number of accordion panels. And made sure it's a full render each time, by updating the id. I have also passed the title as a prop to log the title.
Then I logged the calculated count and title (FwbAccordionPanel.vue)
Here is the result