mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
feat: improve async actions docs and guards (#4215)
* docs: clarify submit handler in standalone example * docs: clarify protection against re-running actions * docs: clarify that these directives replace click and ngSubmit * docs: clarify `void` * feat: disable action directive on bitsubmit disable * docs: fix grammar * docs: change to note * feat: guard against double running bitAction
This commit is contained in:
@@ -14,8 +14,10 @@ import { BitActionDirective } from ".";
|
||||
* - Activates the button loading effect while the form is processing an async submit action.
|
||||
* - Disables the button while a `bitAction` directive on another button is being processed.
|
||||
*
|
||||
* When attached to a standalone button with `bitAction` directive:
|
||||
* - Disables the form while the `bitAction` directive is processing an async submit action.
|
||||
* When attached to a button with `bitAction` directive inside of a form:
|
||||
* - Disables the button while the `bitSubmit` directive is processing an async submit action.
|
||||
* - Disables the button while a `bitAction` directive on another button is being processed.
|
||||
* - Disables form submission while the `bitAction` directive is processing an async action.
|
||||
*/
|
||||
@Directive({
|
||||
selector: "button[bitFormButton]",
|
||||
@@ -48,6 +50,10 @@ export class BitFormButtonDirective implements OnDestroy {
|
||||
actionDirective.loading$.pipe(takeUntil(this.destroy$)).subscribe((disabled) => {
|
||||
submitDirective.disabled = disabled;
|
||||
});
|
||||
|
||||
submitDirective.disabled$.pipe(takeUntil(this.destroy$)).subscribe((disabled) => {
|
||||
actionDirective.disabled = disabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user