Skip to content

Commit

Permalink
feat(ui5-panel): noAnimation property introduced (#3694)
Browse files Browse the repository at this point in the history
FIXES: #3505
  • Loading branch information
niyap authored and ilhan007 committed Aug 26, 2021
1 parent eb8fcf9 commit d58bf44
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
22 changes: 17 additions & 5 deletions packages/main/src/Panel.js
Expand Up @@ -95,7 +95,19 @@ const metadata = {
},

/**
* Sets the accessible aria role of the <code>ui5-panel</code>.
* Indicates whether the transition between the expanded and the collapsed state of the component is animated. By default the animation is enabled.
*
* @type {boolean}
* @defaultvalue false
* @public
* @since 1.0.0-rc.16
*/
noAnimation: {
type: Boolean,
},

/**
* Sets the accessible aria role of the component.
* Depending on the usage, you can change the role from the default <code>Form</code>
* to <code>Region</code> or <code>Complementary</code>.
*
Expand Down Expand Up @@ -282,8 +294,8 @@ class Panel extends UI5Element {
return true;
}

shouldAnimate() {
return getAnimationMode() !== AnimationMode.None;
shouldNotAnimate() {
return this.noAnimation || getAnimationMode() === AnimationMode.None;
}

_headerClick(event) {
Expand Down Expand Up @@ -332,7 +344,7 @@ class Panel extends UI5Element {

this.collapsed = !this.collapsed;

if (!this.shouldAnimate()) {
if (this.shouldNotAnimate()) {
this.fireEvent("toggle");
return;
}
Expand Down Expand Up @@ -368,7 +380,7 @@ class Panel extends UI5Element {
get classes() {
return {
headerBtn: {
"ui5-panel-header-button-animated": this.shouldAnimate(),
"ui5-panel-header-button-animated": !this.shouldNotAnimate(),
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test/pages/Panel.html
Expand Up @@ -58,7 +58,7 @@
}
</style>

<ui5-panel id="p1" collapsed accessible-role="Complementary">
<ui5-panel id="p1" collapsed accessible-role="Complementary" no-animation>

<!-- Panel header -->
<div slot="header" class="header">
Expand Down
8 changes: 8 additions & 0 deletions packages/main/test/specs/Panel.spec.js
Expand Up @@ -97,6 +97,14 @@ describe("Panel general interaction", () => {
assert.strictEqual(field.getProperty("value"), "3", "Press should be called 3 times");
});

it("tests toggle expand/collapse animation", () => {
const panelWithAnimationIcon = browser.$("#panel-expandable").shadow$(".ui5-panel-header-button");
const panelWithoutAnimationIcon = browser.$("#p1").shadow$(".ui5-panel-header-button");

assert.ok(panelWithAnimationIcon.hasClass("ui5-panel-header-button-animated"), "Animation is presented");
assert.notOk(panelWithoutAnimationIcon.hasClass("ui5-panel-header-button-animated"), "Animation is turn off");
});

describe("Accessibility", () => {

it("tests whether aria attributes are set correctly with native header", () => {
Expand Down

0 comments on commit d58bf44

Please sign in to comment.