Skip to content

Commit cc4ab19

Browse files
authored
chore(ui5-button): new nonInteractive property (#2942)
Added new nonInteractive private property which removes hover, active states and it can't be accessed thought Tab key and mouse.
1 parent ad7adc5 commit cc4ab19

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

packages/main/src/Button.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const metadata = {
195195
* Indicates if the element if focusable
196196
* @private
197197
*/
198-
nonFocusable: {
198+
nonInteractive: {
199199
type: Boolean,
200200
},
201201

@@ -333,6 +333,9 @@ class Button extends UI5Element {
333333
}
334334

335335
_onclick(event) {
336+
if (this.nonInteractive) {
337+
return;
338+
}
336339
event.isMarked = "button";
337340
const FormSupport = getFeature("FormSupport");
338341
if (FormSupport) {
@@ -341,6 +344,9 @@ class Button extends UI5Element {
341344
}
342345

343346
_onmousedown(event) {
347+
if (this.nonInteractive) {
348+
return;
349+
}
344350
event.isMarked = "button";
345351
this.active = true;
346352
activeButton = this; // eslint-disable-line
@@ -365,11 +371,18 @@ class Button extends UI5Element {
365371
}
366372

367373
_onfocusout(_event) {
374+
if (this.nonInteractive) {
375+
return;
376+
}
368377
this.active = false;
369378
this.focused = false;
370379
}
371380

372381
_onfocusin(event) {
382+
if (this.nonInteractive) {
383+
return;
384+
}
385+
373386
event.isMarked = "button";
374387
this.focused = true;
375388
}
@@ -417,7 +430,7 @@ class Button extends UI5Element {
417430
return tabindex;
418431
}
419432

420-
return this.nonFocusable ? "-1" : this._tabIndex;
433+
return this.nonInteractive ? "-1" : this._tabIndex;
421434
}
422435

423436
get showIconTooltip() {

packages/main/src/themes/Button.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
line-height: inherit;
6262
}
6363

64-
:host(:not([active]):hover),
64+
:host(:not([active]):not([non-interactive]):hover),
6565
:host(:not([hidden]).ui5_hovered) {
6666
background: var(--sapButton_Hover_Background);
6767
}

0 commit comments

Comments
 (0)