Skip to content

Commit 1731e6b

Browse files
yanaminkovailhan007
authored andcommitted
refactor(ui5-checkbox): wrap text by default (#9165)
The text of `ui5-checkbox` now wraps by default. BREAKING CHANGE: `wrapping-type` property default value has changed from `None` to `Normal`. Before: ```html <ui5-checkbox text=Some very very very very long text"></ui5-checkbox><!-- would truncate the text if there is not enough space --> ``` Now: ```html <ui5-checkbox text=Some very very very very long text"></ui5-checkbox> <!-- would let the text wrap if there is not enough space --> ``` Related to #8461, #7887
1 parent ea2e31f commit 1731e6b

File tree

7 files changed

+26
-20
lines changed

7 files changed

+26
-20
lines changed

packages/main/src/CheckBox.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let activeCb: CheckBox;
5151
* ### Usage
5252
*
5353
* You can define the checkbox text with via the `text` property. If the text exceeds the available width, it is truncated by default.
54-
* In case you prefer text to wrap, set the `wrappingType` property to "Normal".
54+
* In case you prefer text to truncate, set the `wrappingType` property to "None".
5555
* The touchable area for toggling the `ui5-checkbox` ends where the text ends.
5656
*
5757
* You can disable the `ui5-checkbox` by setting the `disabled` property to
@@ -208,10 +208,11 @@ class CheckBox extends UI5Element implements IFormInputElement {
208208
* Defines whether the component text wraps when there is not enough space.
209209
*
210210
* **Note:** for option "Normal" the text will wrap and the words will not be broken based on hyphenation.
211-
* @default "None"
211+
* **Note:** for option "None" the text will be truncated with an ellipsis.
212+
* @default "Normal"
212213
* @public
213214
*/
214-
@property({ type: WrappingType, defaultValue: WrappingType.None })
215+
@property({ type: WrappingType, defaultValue: WrappingType.Normal })
215216
wrappingType!: `${WrappingType}`;
216217

217218
/**

packages/main/src/themes/CheckBox.css

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,26 @@
4343
}
4444

4545
/* wrap */
46-
:host([wrapping-type="Normal"][text]) .ui5-checkbox-root {
46+
:host(:not([wrapping-type="None"])[text]) .ui5-checkbox-root {
4747
min-height: auto;
4848
box-sizing: border-box;
4949
align-items: flex-start;
5050
padding-top: var(--_ui5_checkbox_root_side_padding);
5151
padding-bottom: var(--_ui5_checkbox_root_side_padding);
5252
}
5353

54-
:host([wrapping-type="Normal"][text]) .ui5-checkbox-root .ui5-checkbox-inner,
55-
:host([wrapping-type="Normal"][text]) .ui5-checkbox-root .ui5-checkbox-label {
54+
:host(:not([wrapping-type="None"])[text]) .ui5-checkbox-root .ui5-checkbox-inner,
55+
:host(:not([wrapping-type="None"])[text]) .ui5-checkbox-root .ui5-checkbox-label {
5656
margin-top: var(--_ui5_checkbox_wrapped_content_margin_top);
5757
}
5858

59-
:host([wrapping-type="Normal"][text]) .ui5-checkbox-root .ui5-checkbox-label {
59+
:host(:not([wrapping-type="None"])[text]) .ui5-checkbox-root .ui5-checkbox-label {
6060
overflow-wrap: break-word;
6161
align-self: center;
6262
}
6363

64-
:host([desktop][wrapping-type="Normal"]) .ui5-checkbox-root:focus::before,
65-
:host([wrapping-type="Normal"]) .ui5-checkbox-root:focus-visible::before {
64+
:host([desktop]:not([wrapping-type="None"])) .ui5-checkbox-root:focus::before,
65+
.ui5-checkbox-root:focus-visible::before {
6666
bottom: var(--_ui5_checkbox_wrapped_focus_left_top_bottom_position);
6767
}
6868

packages/main/test/pages/CheckBox.html

+10-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<ui5-checkbox id="cbReadonly" readonly text="Option"></ui5-checkbox>
2121
<ui5-checkbox id="cbDisabled" disabled text="Option"></ui5-checkbox>
2222
<ui5-checkbox id="cbError" value-state="Negative" text="Option"></ui5-checkbox>
23-
<ui5-checkbox id="truncatingCb" text="Long long long text that should truncate at some point" class="checkbox2auto"></ui5-checkbox>
24-
<ui5-checkbox text="Long long long text that should truncate at some point"></ui5-checkbox>
23+
<ui5-checkbox id="wrappingCb" text="Long long long text that should wrap at some point" class="checkbox2auto"></ui5-checkbox>
24+
<ui5-checkbox wrapping-type="None" text="Long long long text that should truncate at some point"></ui5-checkbox>
2525

2626
<ui5-title>In Container - stretches to the container</ui5-title>
2727
<div class="checkbox3auto">
@@ -35,9 +35,14 @@
3535
</div>
3636

3737
<br><br>
38-
<ui5-title>Text Wrapping</ui5-title>
39-
<ui5-checkbox id="wrappingCb" wrapping-type="Normal" class="ui5-cb-testing-wrap checkbox2auto" text="Longest ever text written in English that have to wraps because it is so long of course!" ></ui5-checkbox>
40-
<ui5-checkbox wrapping-type="Normal" text="Longest ever text written in English that wraps because it's too long of course!" class="checkbox2auto"></ui5-checkbox>
38+
<ui5-title>wrappingType="Normal" (default value)</ui5-title>
39+
<ui5-checkbox class="ui5-cb-testing-wrap checkbox2auto" text="Longest ever text written in English that have to wrap because it is so long of course!" ></ui5-checkbox>
40+
<ui5-checkbox text="Longest ever text written in English that wraps because it's too long of course!" class="checkbox2auto"></ui5-checkbox>
41+
42+
<br><br>
43+
<ui5-title>wrappingType="None"</ui5-title>
44+
<ui5-checkbox id="truncatingCb" wrapping-type="None" class="ui5-cb-testing-wrap checkbox2auto" text="Longest ever text written in English that have to truncate because it is so long of course!" ></ui5-checkbox>
45+
<ui5-checkbox wrapping-type="None" text="Longest ever text written in English that truncates because it's too long of course!" class="checkbox2auto"></ui5-checkbox>
4146

4247
<br><br>
4348
<ui5-title>Change Event Test</ui5-title>

packages/main/test/pages/Kitchen.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
<section class="row row-centered">
243243
<ui5-checkbox id="myCb1" checked text="Default"></ui5-checkbox>
244244
<ui5-checkbox id="myCb2" read-only text="read only"></ui5-checkbox>
245-
<ui5-checkbox id="myCb3" disabled wrapping-type="Normal" text="disabled long text might also wrap"></ui5-checkbox>
245+
<ui5-checkbox id="myCb3" disabled text="disabled long text might also wrap"></ui5-checkbox>
246246
<ui5-checkbox id="myCb4" read-only text="read only" checked></ui5-checkbox>
247247
<ui5-checkbox id="myCb5" disabled text="disabled" checked></ui5-checkbox>
248248
<ui5-checkbox id="myCb6" value-state="Critical" checked text="warning"></ui5-checkbox>

packages/main/test/pages/Kitchen.openui5.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
<section class="row row-centered">
225225
<ui5-checkbox id="myCb1" checked text="Default"></ui5-checkbox>
226226
<ui5-checkbox id="myCb2" read-only text="read only"></ui5-checkbox>
227-
<ui5-checkbox id="myCb3" disabled wrapping-type="Normal" text="disabled long text might also wrap"></ui5-checkbox>
227+
<ui5-checkbox id="myCb3" disabled text="disabled long text might also wrap"></ui5-checkbox>
228228
<ui5-checkbox id="myCb4" read-only text="read only" checked></ui5-checkbox>
229229
<ui5-checkbox id="myCb5" disabled text="disabled" checked></ui5-checkbox>
230230
<ui5-checkbox id="myCb6" value-state="Critical" checked text="warning"></ui5-checkbox>

packages/website/docs/_components_pages/main/CheckBox.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CheckBox supports several semantic value states, readonly, disabled, etc.
2828
<States />
2929

3030
### Text Truncation and Wrapping
31-
The CheckBox text truncates by default. To make it wrap - set <b>wrapping-type="Normal"</b>.
31+
The CheckBox text wraps by default. To make it truncate - set <b>wrapping-type="None"</b>.
3232

3333
<TextWrapping />
3434

packages/website/docs/_samples/main/CheckBox/TextWrapping/sample.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
<!-- playground-fold-end -->
1313

1414
<ui5-checkbox
15-
text="Truncating text when 'wrapping-type=Normal' set and some long text."
15+
text="Truncating text when 'wrapping-type=None' set and some long text."
1616
style="width:200px;"
17+
wrapping-type="None"
1718
></ui5-checkbox>
1819

1920
<br>
2021

2122
<ui5-checkbox
2223
checked
23-
wrapping-type="Normal"
24-
text="Wrapping text when 'wrapping-type=Normal' set and some long text."
24+
text="Wrapping text when the components is with its default 'wrapping-type=Normal' and some long text."
2525
style="width:200px;"
2626
></ui5-checkbox>
2727
<!-- playground-fold -->

0 commit comments

Comments
 (0)