Skip to content

Commit 4f2abdd

Browse files
authored
refactor(ui5-color-palette-popover): deprecate openPopover (#4613)
Deprecate openPopover in favour of "showAt" to be consistent with Popover, ResponsivePopover
1 parent d04cf8c commit 4f2abdd

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

packages/main/src/ColorPalettePopover.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,30 @@ class ColorPalettePopover extends UI5Element {
169169
return this.responsivePopover.content[0].querySelector("[ui5-color-palette]");
170170
}
171171

172-
closePopover() {
173-
this.responsivePopover.close();
172+
/**
173+
* Shows the ColorPalettePopover.
174+
* @param {HTMLElement} opener the element that the popover is shown at
175+
* @public
176+
* @since 1.1.1
177+
*/
178+
showAt(opener) {
179+
this._openPopover(opener);
174180
}
175181

182+
/**
183+
* Shows the ColorPalettePopover.
184+
* <b>Note:</b> The method is deprecated and will be removed in future, use <code>showAt</code> instead.
185+
* @param {HTMLElement} opener the element that the popover is shown at
186+
* @public
187+
* @since 1.0.0-rc.16
188+
* @deprecated The method is deprecated in favour of <code>showAt</code>.
189+
*/
176190
openPopover(opener) {
191+
console.warn("The method 'openPopover' is deprecated and will be removed in future, use 'showAt' instead."); // eslint-disable-line
192+
this._openPopover(opener);
193+
}
194+
195+
_openPopover(opener) {
177196
this._respPopover();
178197

179198
this.responsivePopover.showAt(opener, true);
@@ -185,6 +204,10 @@ class ColorPalettePopover extends UI5Element {
185204
}
186205
}
187206

207+
closePopover() {
208+
this.responsivePopover.close();
209+
}
210+
188211
onSelectedColor(event) {
189212
this.closePopover();
190213
this.fireEvent("item-click", event.detail);

packages/main/test/pages/ColorPalettePopover.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,22 @@
119119
</ui5-color-palette-popover>
120120
<script>
121121
colorPaletteBtn.addEventListener("click", function(event) {
122-
colorPalettePopover.openPopover(this);
122+
colorPalettePopover.showAt(this);
123123
});
124124
colorPaletteBtn1.addEventListener("click", function(event) {
125-
colorPalettePopover1.openPopover(this);
125+
colorPalettePopover1.showAt(this);
126126
});
127127
colorPaletteBtn2.addEventListener("click", function(event) {
128-
colorPalettePopover2.openPopover(this);
128+
colorPalettePopover2.showAt(this);
129129
});
130130
colorPaletteBtn3.addEventListener("click", function(event) {
131-
colorPalettePopover3.openPopover(this);
131+
colorPalettePopover3.showAt(this);
132132
});
133133
colorPaletteBtn4.addEventListener("click", function(event) {
134-
colorPalettePopover4.openPopover(this);
134+
colorPalettePopover4.showAt(this);
135135
});
136136
colorPaletteBtn5.addEventListener("click", function(event) {
137-
colorPalettePopover5.openPopover(this);
137+
colorPalettePopover5.showAt(this);
138138
});
139139
</script>
140140
</html>

packages/main/test/samples/ColorPalettePopover.sample.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h3>Color Palette Popover with recent colors, default color and more colors feat
2727
</div>
2828
<script>
2929
colorPaletteBtn.addEventListener("click", function(event) {
30-
colorPalettePopover.openPopover(this);
30+
colorPalettePopover.showAt(this);
3131
});
3232
</script>
3333
<pre class="prettyprint lang-html"><xmp>
@@ -48,7 +48,7 @@ <h3>Color Palette Popover with recent colors, default color and more colors feat
4848
</ui5-color-palette-popover>
4949
<script>
5050
colorPaletteBtn.addEventListener("click", (event) => {
51-
colorPalettePopover.openPopover(this);
51+
colorPalettePopover.showAt(this);
5252
});
5353
</script>
5454
</xmp></pre>
@@ -75,7 +75,7 @@ <h3>Color Palette Popover without any additional features</h3>
7575
</div>
7676
<script>
7777
colorPaletteBtn1.addEventListener("click", function (event) {
78-
colorPalettePopover1.openPopover(this);
78+
colorPalettePopover1.showAt(this);
7979
});
8080
</script>
8181
<pre class="prettyprint lang-html"><xmp>
@@ -96,7 +96,7 @@ <h3>Color Palette Popover without any additional features</h3>
9696
</ui5-color-palette-popover>
9797
<script>
9898
colorPaletteBtn1.addEventListener("click", (event) => {
99-
colorPalettePopover1.openPopover(this);
99+
colorPalettePopover1.showAt(this);
100100
});
101101
</script>
102102
</xmp></pre>

0 commit comments

Comments
 (0)