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

Allow more than text on EmptyContent description #3082

Merged
merged 1 commit into from
Aug 23, 2022

Conversation

jotoeri
Copy link
Contributor

@jotoeri jotoeri commented Aug 21, 2022

Adding a slot to NcEmptyContent to put a button below.

There is however still a problem with reactivity, when using multiple NcEmptyContent 'after' each other.
If i first show an EmptyContent with LoadingIcon only, and after finished loading i want to show an EmptyContent with icon and text, then the text is not shown. Same applies to Icon (Action, Desc), if a slot is not used on the first usage, but should be shown on the second. (Example in nextcloud/forms#1308)
@raimund-schluessler @skjnldsv @Pytal Any idea, how to fix the emptyContent reactivity here? Seems like there was some attempt to fix reactivity in #2867, but did this maybe introduce the problem? 🙈

Screenshot from 2022-08-21 21-26-58

@jotoeri jotoeri added help wanted Extra attention is needed 2. developing Work in progress labels Aug 21, 2022
@Pytal
Copy link
Contributor

Pytal commented Aug 22, 2022

I cannot reproduce this @jotoeri, works when e.g. starting with no icon then toggling the icon like this

<template #icon>
	<Airplane v-if="show" />
</template>

but doesn't when doing

<template v-if="show" #icon>
	<Airplane />
</template>

@jotoeri
Copy link
Contributor Author

jotoeri commented Aug 22, 2022

You can have a look into nextcloud/forms#1308

What i'm trying to do is:

<NcEmptyContent v-if="loading">
	<template #icon>
		<Airplane />
	</template>
</NcEmptyContent>
<NcEmptyContent v-else>
	<template #icon>
		<Airplane />
	</template>
	{{ t('forms', 'Some translated text') }}
</NcEmptyContent>

But the Text then doesn't show up.

You can do it even more clear like this, where the icon does not show up:

<NcEmptyContent v-if="loading">
	{{ t('forms', 'Some translated text') }}
</NcEmptyContent>
<NcEmptyContent v-else>
	<template #icon>
		<Airplane />
	</template>
	{{ t('forms', 'Some translated text') }}
</NcEmptyContent>

However, here the icon shows up on the second EmptyContent:

<NcEmptyContent v-if="loading">
	<template #icon>
		<div />
	</template>
	{{ t('forms', 'Some translated text') }}
</NcEmptyContent>
<NcEmptyContent v-else>
	<template #icon>
		<Airplane />
	</template>
	{{ t('forms', 'Some translated text') }}
</NcEmptyContent>

@skjnldsv
Copy link
Contributor

Why not use the description?
That seems appropriate to add any content but the title?

@jotoeri
Copy link
Contributor Author

jotoeri commented Aug 22, 2022

Why not use the description?

Currently the description is constrained to text-only and the EmptyContent on forms (created by you 😉) had a description-slot as well as an action-slot. This is why i went this way. But i'm also fine with opening the desc-slot to any content.

@Pytal
Copy link
Contributor

Pytal commented Aug 22, 2022

We could put the v-if/v-else not on NcEmptyContent itself but on the icon or text used inside NcEmptyContent, would that work @jotoeri?

@jotoeri
Copy link
Contributor Author

jotoeri commented Aug 23, 2022

Didnt test yet, but from your example above i also thought that could be a workaround. However:

  • Makes the code less logical, as in fact i want to show different Emptycontents as a total.
  • It's a workaround, that does not solve the issue, that normally the component should work with my code above.

@skjnldsv
Copy link
Contributor

Why not use the description?

Currently the description is constrained to text-only and the EmptyContent on forms (created by you wink) had a description-slot as well as an action-slot. This is why i went this way. But i'm also fine with opening the desc-slot to any content.

Would be simpler to widen the description imho

Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
@jotoeri jotoeri changed the title Add Action Slot to emptyContent Allow more than text on EmptyContent description Aug 23, 2022
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 23, 2022
@skjnldsv skjnldsv added feature: emptycontent Related to the emptycontent component enhancement New feature or request and removed help wanted Extra attention is needed labels Aug 23, 2022
Copy link
Contributor

@raimund-schluessler raimund-schluessler left a comment

Choose a reason for hiding this comment

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

Very good, this saves me this hacked solution of putting &nbsp; in the description to show the buttons:
https://github.com/nextcloud/tasks/blob/0611f1b897c4681035b7e6541247dd4dcc9cea44/src/components/TaskCreateDialog.vue#L77-L85

@raimund-schluessler raimund-schluessler merged commit 7b09608 into master Aug 23, 2022
@raimund-schluessler raimund-schluessler deleted the enh/emptyContent_action branch August 23, 2022 07:08
@skjnldsv skjnldsv mentioned this pull request Aug 23, 2022
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 enhancement New feature or request feature: emptycontent Related to the emptycontent component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants