-
Notifications
You must be signed in to change notification settings - Fork 279
feat(ui5-button): Add BusyIndicator #11906
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
base: main
Are you sure you want to change the base?
Changes from all commits
0e0d4d1
3a26280
79e70aa
f14d013
b805686
b9964b0
1962be2
b692a21
7b6b898
ae4bc15
1475f14
3ef3b12
bdf1e56
6526dca
b386727
5c0344e
54636c4
1258347
420238c
44a4d02
bfd6ae1
c8dc14d
a4c0ab1
7b1d828
af1109d
2d4d825
96ae6d5
17fd6ba
cc36fbb
8de3c62
9c51de8
0cf7af8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,7 +313,28 @@ class Button extends UI5Element implements IButton { | |
nonInteractive = false; | ||
|
||
/** | ||
* The current title of the button, either the tooltip property or the icons tooltip. The tooltip property with higher prio. | ||
* Defines whether the button shows a loading indicator. | ||
* | ||
* **Note:** If set to `true`, a busy indicator component will be displayed on the related button. | ||
* @default false | ||
* @public | ||
* @since 2.13.0 | ||
*/ | ||
@property({ type: Boolean }) | ||
loading = false; | ||
|
||
/** | ||
* Specifies the delay in milliseconds before the loading indicator appears within the associated button. | ||
* @default 1000 | ||
* @public | ||
* @since 2.13.0 | ||
*/ | ||
@property({ type: Number }) | ||
loadingDelay = 1000; | ||
|
||
/** | ||
* The button's current title is determined by either the `tooltip` property or the icon's tooltip, with the `tooltip` | ||
* property taking precedence if both are set. | ||
* @private | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please consider paraphrasing: The button's current title is determined by either the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in cc36fbb |
||
*/ | ||
@property({ noAttribute: true }) | ||
|
@@ -448,6 +469,11 @@ class Button extends UI5Element implements IButton { | |
return; | ||
} | ||
|
||
if (this.loading) { | ||
e.preventDefault(); | ||
return; | ||
} | ||
|
||
const { | ||
altKey, | ||
ctrlKey, | ||
|
@@ -482,7 +508,7 @@ class Button extends UI5Element implements IButton { | |
} | ||
|
||
_onmousedown() { | ||
if (this.nonInteractive) { | ||
if (this.nonInteractive || this.loading) { | ||
return; | ||
} | ||
|
||
|
@@ -491,7 +517,7 @@ class Button extends UI5Element implements IButton { | |
} | ||
|
||
_ontouchend(e: TouchEvent) { | ||
if (this.disabled) { | ||
if (this.disabled || this.loading) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
} | ||
|
@@ -506,7 +532,7 @@ class Button extends UI5Element implements IButton { | |
} | ||
|
||
_onkeydown(e: KeyboardEvent) { | ||
this._cancelAction = isShift(e) || isEscape(e); | ||
this._cancelAction = isShift(e) || isEscape(e) || this.loading; | ||
|
||
if (isSpace(e) || isEnter(e)) { | ||
this._setActiveState(true); | ||
|
@@ -528,7 +554,7 @@ class Button extends UI5Element implements IButton { | |
} | ||
|
||
_onfocusout() { | ||
if (this.nonInteractive) { | ||
if (this.nonInteractive || this.loading) { | ||
return; | ||
} | ||
|
||
|
@@ -540,7 +566,7 @@ class Button extends UI5Element implements IButton { | |
_setActiveState(active: boolean) { | ||
const eventPrevented = !this.fireDecoratorEvent("active-state-change"); | ||
|
||
if (eventPrevented) { | ||
if (eventPrevented || this.loading) { | ||
return; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import html from '!!raw-loader!./sample.html'; | ||
import js from '!!raw-loader!./main.js'; | ||
|
||
<Editor html={html} js={js} /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import "@ui5/webcomponents/dist/Button.js"; | ||
|
||
import "@ui5/webcomponents-icons/dist/edit.js"; | ||
import "@ui5/webcomponents-icons/dist/employee.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- playground-fold --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Sample</title> | ||
</head> | ||
|
||
<body style="background-color: var(--sapBackgroundColor)"> | ||
<!-- playground-fold-end --> | ||
<div> | ||
<br/> | ||
<ui5-button icon="sap-icon://edit" tooltip="Accept terms & conditions" loading></ui5-button> | ||
<ui5-button loading>Loading</ui5-button> | ||
<ui5-button icon="sap-icon://employee" loading>Loading</ui5-button> | ||
<ui5-button design="Transparent" loading>Loading</ui5-button> | ||
<ui5-button icon="sap-icon://employee" design="Transparent" loading>Loading</ui5-button> | ||
<ui5-button design="Emphasized" loading>Loading</ui5-button> | ||
<ui5-button icon="sap-icon://employee" design="Emphasized" loading>Loading</ui5-button> | ||
<ui5-button design="Positive" loading>Loading</ui5-button> | ||
<ui5-button icon="sap-icon://employee" design="Positive" loading>Loading</ui5-button> | ||
<ui5-button design="Negative" loading>Loading</ui5-button> | ||
<ui5-button icon="sap-icon://employee" design="Negative" loading>Loading</ui5-button> | ||
</div> | ||
<!-- playground-fold --> | ||
<script type="module" src="main.js"></script> | ||
</body> | ||
|
||
</html> | ||
<!-- playground-fold-end --> |
Uh oh!
There was an error while loading. Please reload this page.