Skip to content

Commit 724025b

Browse files
authoredJun 8, 2021
refactor(ui5-radiobutton): replace wrap with wrappingType (#3409)
As part of #3107 we decided to replace the boolean property wrap as we expect to add a new type of wrapping (Hyphenated) and for this the string property from enum type is more suitable. BREAKING_CHANGE: The boolean property wrap has been removed in favour of string prop wrappingType. If you previously used wrap, now set wrappingType="Normal" instead.
1 parent 85143e9 commit 724025b

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed
 

‎packages/main/src/RadioButton.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</div>
2222

2323
{{#if text}}
24-
<ui5-label id="{{_id}}-label" class="ui5-radio-label" for="{{_id}}" wrapping-type="{{_wrappingType}}">{{text}}</ui5-label>
24+
<ui5-label id="{{_id}}-label" class="ui5-radio-label" for="{{_id}}" wrapping-type="{{wrappingType}}">{{text}}</ui5-label>
2525
{{/if}}
2626

2727
{{#if hasValueState}}

‎packages/main/src/RadioButton.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
isRight,
1414
} from "@ui5/webcomponents-base/dist/Keys.js";
1515
import Label from "./Label.js";
16-
import WrappingType from "./types/WrappingType.js";
1716
import RadioButtonGroup from "./RadioButtonGroup.js";
17+
import WrappingType from "./types/WrappingType.js";
1818

1919
// Template
2020
import RadioButtonTemplate from "./generated/templates/RadioButtonTemplate.lit.js";
@@ -153,14 +153,19 @@ const metadata = {
153153
/**
154154
* Defines whether the component text wraps when there is not enough space.
155155
* <br><br>
156-
* <b>Note:</b> By default, the text truncates when there is not enough space.
156+
* Available options are:
157+
* <ul>
158+
* <li><code>None</code> - The text will be truncated with an ellipsis.</li>
159+
* <li><code>Normal</code> - The text will wrap. The words will not be broken based on hyphenation.</li>
160+
* </ul>
157161
*
158-
* @type {boolean}
159-
* @defaultvalue false
162+
* @type {WrappingType}
163+
* @defaultvalue "None"
160164
* @public
161165
*/
162-
wrap: {
163-
type: Boolean,
166+
wrappingType: {
167+
type: WrappingType,
168+
defaultValue: WrappingType.None,
164169
},
165170

166171
_tabIndex: {
@@ -260,10 +265,6 @@ class RadioButton extends UI5Element {
260265
onBeforeRendering() {
261266
this.syncGroup();
262267

263-
/* temporary workaround. remove after all wrap properties in the relevant components are renamed to wrappingType */
264-
this._wrappingType = this.wrap ? WrappingType.Normal : WrappingType.None;
265-
/* end */
266-
267268
this._enableFormSupport();
268269
}
269270

‎packages/main/src/themes/RadioButton.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@
145145
pointer-events: none;
146146
}
147147

148-
:host([wrap][text]) .ui5-radio-root {
148+
:host([wrapping-type="Normal"][text]) .ui5-radio-root {
149149
height: auto;
150150
}
151151

152-
:host([wrap][text]) [ui5-label].ui5-radio-label {
152+
:host([wrapping-type="Normal"][text]) [ui5-label].ui5-radio-label {
153153
padding: var(--_ui5_rb_label_side_padding) 0;
154154
word-break: break-all;
155155
}

‎packages/main/test/pages/RadioButton.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@
8383
<section class="radio-section">
8484
<ui5-radiobutton id="rb1"></ui5-radiobutton>
8585
<ui5-radiobutton id="rb2" text="Option B"></ui5-radiobutton>
86-
<ui5-radiobutton id="rb3" wrap text="Option C"></ui5-radiobutton>
86+
<ui5-radiobutton id="rb3" wrapping-type="Normal" text="Option C"></ui5-radiobutton>
8787
<ui5-radiobutton id="rb4" disabled text="Option D"></ui5-radiobutton>
8888
<ui5-radiobutton id="truncatingRb" text="Long long long text that should truncate at some point">></ui5-radiobutton>
8989
<br/>
90-
<ui5-radiobutton id="wrappingRb" wrap text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s." style="width: 300px"></ui5-radiobutton>
90+
<ui5-radiobutton id="wrappingRb" wrapping-type="Normal" text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s." style="width: 300px"></ui5-radiobutton>
9191
<ui5-input id="field"></ui5-input>
9292
</section>
9393

‎packages/main/test/samples/RadioButton.sample.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ <h3>RadioButton in group - navigate via [UP/Right] and [DOWN/Left] arrow keys</h
6969
<section>
7070
<h3>RadioButton with Text Wrapping</h3>
7171
<div class="snippet">
72-
<ui5-radiobutton text="ui5-radiobutton with 'wrap' set and some long text" wrap style="width:200px"></ui5-radiobutton>
73-
<ui5-radiobutton text="Another ui5-radiobutton with very long text here" wrap style="width:200px"></ui5-radiobutton>
72+
<ui5-radiobutton text="ui5-radiobutton with 'wrapping-type=Normal' set and some long text" wrapping-type="Normal" style="width:200px"></ui5-radiobutton>
73+
<ui5-radiobutton text="Another ui5-radiobutton with very long text here" wrapping-type="Normal" style="width:200px"></ui5-radiobutton>
7474
</div>
7575
<pre class="prettyprint lang-html"><xmp>
76-
<ui5-radiobutton text="ui5-radiobutton with 'wrap' set and some long text" wrap></ui5-radiobutton>
77-
<ui5-radiobutton text="Another ui5-radiobutton with very long text here" wrap></ui5-radiobutton>
76+
<ui5-radiobutton text="ui5-radiobutton with 'wrapping-type=Normal' set and some long text" wrapping-type="Normal"></ui5-radiobutton>
77+
<ui5-radiobutton text="Another ui5-radiobutton with very long text here" wrapping-type="Normal"></ui5-radiobutton>
7878
</xmp></pre>
7979
</section>
8080

‎packages/main/test/specs/RadioButton.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ describe("RadioButton general interaction", () => {
150150
const truncatingRbHeight = truncatingRb.getSize("height");
151151
const wrappingRbHeight = wrappingRb.getSize("height");
152152

153-
assert.ok(!truncatingRb.getProperty("wrap"), "The text should not be wrapped.");
154-
assert.ok(wrappingRb.getProperty("wrap"), "The text should be wrapped.");
153+
assert.ok(truncatingRb.getProperty("wrappingType") === "None", "The text should not be wrapped.");
154+
assert.ok(wrappingRb.getProperty("wrappingType") === "Normal", "The text should be wrapped.");
155155

156156
assert.strictEqual(truncatingRbHeight, RADIOBUTTON_DEFAULT_HEIGHT, "The size of the radiobutton is : " + truncatingRbHeight);
157157
assert.ok(wrappingRbHeight > RADIOBUTTON_DEFAULT_HEIGHT, "The size of the radiobutton is more than: " + RADIOBUTTON_DEFAULT_HEIGHT);

0 commit comments

Comments
 (0)
Please sign in to comment.