Skip to content
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(NcAppNavigationItem): use $scopedSlots instead of $slots #6161

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

st3iny
Copy link
Contributor

@st3iny st3iny commented Oct 22, 2024

☑️ Resolves

Used to programmatically access scoped slots. For each slot, including the default one, the object contains a corresponding function that returns VNodes.

Ref https://v2.vuejs.org/v2/api/#vm-scopedSlots

🖼️ Screencasts

Before

Bildschirmaufnahme_20241022_194043.webm

After

Bildschirmaufnahme_20241022_193652.webm

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable
  • 3️⃣ Backport to next requested with a Vue 3 upgrade

@st3iny st3iny added bug Something isn't working 3. to review Waiting for reviews feature: app-navigation Related to the app-navigation component labels Oct 22, 2024
@st3iny st3iny self-assigned this Oct 22, 2024
@susnux susnux requested a review from ShGKme October 22, 2024 17:50
Comment on lines 734 to 735
this.hasChildren = !!this.$scopedSlots.default
this.collapsible = this.allowCollapse && !!this.$scopedSlots.default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, $scopedSlots is always available in beforeUpdate in Vue 2.

Also, !!this.$slots.default is false when the is this.$scopedSlots.default with an empty result.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove hasChildren completely, it can be replaced with this.$scopedSlots.default in the template.

And collapsible I'd replace with a method, so we don't change state before update and directly call it during the render.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the logic is a bit hacky. I refactored the code according to your recommendations and pushed another commit.

@st3iny st3iny requested a review from ShGKme October 29, 2024 08:19
Copy link
Contributor

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShGKme
Copy link
Contributor

ShGKme commented Oct 29, 2024

Could you test that it still works dynamically generated content, when the list is empty?

@st3iny
Copy link
Contributor Author

st3iny commented Oct 29, 2024

Could you test that it still works dynamically generated content, when the list is empty?

What exactly do you mean with "dynamically generated content"? I tested it in Mail with my latest changes. The collapse toggle will be shown when there are children (and collapsing is allowed via the prop). Otherwise, it won't be shown.

@st3iny st3iny force-pushed the fix/NcAppNavigationItem/scoped-slots branch from ff8ebf2 to 16702a3 Compare October 29, 2024 13:23
@st3iny
Copy link
Contributor Author

st3iny commented Oct 29, 2024

/backport to next

@st3iny st3iny merged commit c3530bb into master Oct 29, 2024
19 checks passed
@st3iny st3iny deleted the fix/NcAppNavigationItem/scoped-slots branch October 29, 2024 13:51
Copy link

backportbot bot commented Oct 29, 2024

The backport to next failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout next
git pull origin next

# Create the new backport branch
git checkout -b backport/6161/next

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick 16702a37

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/6161/next

Error: No changes found in backport branch


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@ShGKme
Copy link
Contributor

ShGKme commented Oct 29, 2024

What exactly do you mean with "dynamically generated content"? I tested it in Mail with my latest changes. The collapse toggle will be shown when there are children (and collapsing is allowed via the prop). Otherwise, it won't be shown.

When the value of children dynamically changes from 0 to N and back without component re-mounting.

$scopedSlots and $slots are different, especially with the default slot. $scopedSlots.default may not be falsy, while $scopedSlots.default() is actually empty (renders no real content).

Tested on netlify that if works fine now.

@Antreesy Antreesy added this to the 8.20.0 milestone Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews backport-request bug Something isn't working feature: app-navigation Related to the app-navigation component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mailbox actions are broken
4 participants