-
Notifications
You must be signed in to change notification settings - Fork 132
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 Tab-Group Header not displayed #2557
Conversation
The Regardless, this issue might need further investigation 😓 |
<template #header> | ||
<span v-html="t.headerRendered"></span> | ||
</template> |
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.
Instead of making this change (since we rely on the conversions from slots to templates, and do not use header templates directly in our .vue
files), a suggestion I have is to just directly treat the header
as a prop instead, without relying on slot conversion?
In Dropdown.vue
, we can first include the header
as a prop:
props: {
...
header: {
type: String,
default: '',
},
...
And then we can replace the <slot name="header"></slot>
under the v-if
, with {{ header }}
. We could also rename header
to something like tabgroup-header
to differentiate it as well.
This might be a less hacky solution, but if we can investigate the issue deeper and find a better solution, that would be best 👍
It does address my question, thank you! Running it in the debugger with the appropriate breakpoint, I can see it too: Am I right to say that because If this is the case, I agree with your suggestion to treat header as a prop which was done previously as well. It definitely does seem like a better alternative that fits the bigger picture. 😄 |
Hi @gerteck , Thank you for your great research! I concur with your analysis regarding the root cause of this issue. It appears that the nodes are not subject to recursive processing, and the For the immediate solution, I support the two approaches you've outlined:
@lhw-1's suggestions appear reasonable, and I recommend adhering to the second approach. For a more comprehensive solution that might involve modifications to the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2557 +/- ##
=======================================
Coverage 51.86% 51.86%
=======================================
Files 127 127
Lines 5530 5530
Branches 1176 1176
=======================================
Hits 2868 2868
Misses 2367 2367
Partials 295 295 ☔ View full report in Codecov by Sentry. |
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.
Hi @gerteck thanks for the work!
I realised that tabs doesnt have any test cases.. which is why we probably missed out on this regression in behaviour. If you have the time and capacity, you could try writing test cases for tabs. If you don't though, it's ok. Let us know and we will open a issue for this.
@@ -11,7 +11,7 @@ | |||
:class="{'disabled': disabledBool}" | |||
data-bs-toggle="dropdown" | |||
> | |||
<slot name="header"></slot> | |||
<span v-html="tabgroupHeader"></span> |
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.
Hmm I'm not keen on this naming since this is only true for tab groups but not for other headers.
Could we keep the header name?
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.
Sure! The rationale was give greater differentiation in the way the header is passed as a prop instead of relying on slot conversion, but it is evident from the code directly.
I would be down to try writing some test cases for the tabs! Test cases would also prevent any further regressions until a better way to pass down the header is found.
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 just realised that setting it as the same name header causes two of the current tests to fail under dropdown
as the header no longer shows up as an attribute in the html rendered.
This is probably because of the slot name and the attribute prop name having the same name.
With that in mind, I think that the tab-group-header
prop name should be differentiated from the header slot name as it can get confusing as well.
I think we do have some unit test regrading tab-group in |
The header named slot is still being used for navbar, hence removing it causes regression for dropdowns under navbars.
To pass tests
Any feedback on further streamlining and standardizing these changes is highly welcome!! 😄 |
Remove unnecessary import
…/markbind into branch-TabGroupHeaderFix
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.
Thank you for delving into adding snapshot tests for the Vue plugins. I think they are well-written and sufficient to cover the concern of the issue, i.e., Tab-Group Header not displayed in when Dropdown is nested in Tabset.
@Tim-Siu Each PR must have a SEMVER impact label, please remember to label the PR properly. |
@Tim-Siu please replace the commit message with the proposed message whenever you merge the PR in the future. |
Sorry for the mistake. Should I update the commit message and force push? |
Think we can leave it, just take note next time |
What is the purpose of this pull request?
Fixes #2524
Overview of changes:
Header does not show up for the
TabGroup
component. This was likely due to the header being passed as a prop instead of a named slot intoDropdown
.To fix this, pass header as named slot.To fix this, the header is now treated as a prop.Anything you'd like to highlight/discuss:
From what I understand:
TabGroup
internally consists of the dropdown tab component. However, internally, TabGroup does not render this dropdown, but instead adds itself to the parentTabSet
, which is then in charge of rendering childrenTab
orTabGroup
.TabSet
, the header was originally passed into Dropdown from Tabset as an attribute / vue prop ofDropdown
.Dropdown
then uses this prop to display the header:[ Requesting Comments ]: I don't quite understand how the Vue component's prop is being passed as a named slot. Referring to the developer guide, I tried to trace the processing but I think I might be facing a skill issue. I'm confused as it says that "MarkBind attributes are passed to the Vue component as props. The type of the prop will be a String." However, the prop is able to be processed as a named slot.
This seems to be the core of the issue behind the bug. In
Tabset
, the header is being passed intodropdown
similarly as a prop, which is not registered as a namedSlot, and ends up as an attribute when rendered.To fix this, I directly passed the header as a named slot. However the discrepancy and origin of the bug leaves me uneasy.Illustration
Sample Code in MarkBind Syntax (where header is passed as an attribute):
Dropdown Vue Component Template (where header is accepted as a named slot):
markbind/packages/vue-components/src/Dropdown.vue
Lines 28 to 51 in 2c82764
Output:
While the header was passed in as a prop, it is parsed as a named slot.
Some references:
Testing instructions:
Refer to user guide: https://markbind.org/userGuide/components/presentation.html#tabs
Refer to PR's localhost user guide: http://127.0.0.1:8080/userGuide/components/presentation.html#tabs
Before:
After:
Proposed commit message: (wrap lines at 72 characters)
Fix TabGroup Header Rendering Issue
The header for the TabGroup component was not displaying
correctly, due to the header being passed as a prop but
treated as a named slot in the Dropdown component.
To fix this, the header is now treated as a prop.
Checklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major
,r.Minor
,r.Patch
.Breaking change release note preparation (if applicable):