diff --git a/l10n/messages.pot b/l10n/messages.pot
index 9e1c2b52e6..da0ef21167 100644
--- a/l10n/messages.pot
+++ b/l10n/messages.pot
@@ -191,6 +191,10 @@ msgstr ""
msgid "Load more \"{options}\""
msgstr ""
+#. TRANSLATORS: The button is in a loading state
+msgid "Loading …"
+msgstr ""
+
#. TRANSLATORS: A color name for RGB(45, 115, 190)
msgid "Mariner"
msgstr ""
diff --git a/src/components/NcDialog/NcDialog.vue b/src/components/NcDialog/NcDialog.vue
index 53bc6d6c86..c129748fd7 100644
--- a/src/components/NcDialog/NcDialog.vue
+++ b/src/components/NcDialog/NcDialog.vue
@@ -106,7 +106,6 @@ Note that this is not possible if the dialog contains a navigation!
```
+
+### Loading buttons
+Sometimes a dialog ends with a request and this request might fail due to server-side-validation.
+In this case it is often desired to keep the dialog open, this can be done by returning `false` from the button callback,
+to not block this callback should return a `Promise`.
+
+It is also possible to get the result of the callback from the dialog, as the result is passed as the payload of the `closing` event.
+
+While the promise is awaited the button will have a loading state,
+this means, as long as no custom `icon`-slot is used, a loading icon will be shown.
+Please note that the **button will not be disabled or accessibility reasons**,
+because disabled elements cannot be focused and so the loading state could not be communicated e.g. via screen readers.
+
+```vue
+
+
+ Show dialog
+
+
Dialog response: {{ response }}
+
+
+
+```
@@ -137,7 +212,7 @@ export default {
:enable-swipe="false"
v-bind="modalProps"
@close="handleClosed"
- @update:show="handleClosing">
+ @update:show="handleClosing()">
should close
+ * @param {MouseEvent} event The click event
+ * @param {unknown} result Result of the callback function
*/
- const handleButtonClose = () => {
+ const handleButtonClose = (event, result) => {
// Skip close if invalid dialog
if (dialogTagName.value === 'form' && !dialogElement.value.reportValidity()) {
return
}
- handleClosing()
+ handleClosing(result)
window.setTimeout(() => handleClosed(), 300)
}
/**
* Handle closing the dialog, optional out transition did not run yet
+ * @param {unknown} result the result of the callback
*/
- const handleClosing = () => {
+ const handleClosing = (result) => {
showModal.value = false
/**
- * Emitted when the dialog is closing, so the out transition did not finish yet
+ * Emitted when the dialog is closing, so the out transition did not finish yet.
+ * @param result The result of the button callback (`undefined` if closing because of clicking the 'close'-button)
*/
- emit('closing')
+ emit('closing', result)
}
/**
diff --git a/src/components/NcDialogButton/NcDialogButton.vue b/src/components/NcDialogButton/NcDialogButton.vue
index b1bb762157..609b13baa5 100644
--- a/src/components/NcDialogButton/NcDialogButton.vue
+++ b/src/components/NcDialogButton/NcDialogButton.vue
@@ -17,103 +17,116 @@ Dialog button component used by NcDialog in the actions slot to display the butt
-
+
+
+
-
diff --git a/styleguide.config.cjs b/styleguide.config.cjs
index 981e528fb1..73e94f1550 100644
--- a/styleguide.config.cjs
+++ b/styleguide.config.cjs
@@ -66,6 +66,9 @@ module.exports = async () => {
},
enhancePreviewApp: path.resolve(__dirname, 'styleguide/preview.js'),
+ compilerConfig: {
+ transforms: { asyncAwait: false },
+ },
sections: [
{