File tree 6 files changed +71
-22
lines changed
6 files changed +71
-22
lines changed Original file line number Diff line number Diff line change 20
20
<input type =' radio' ?checked =" {{ selected }} " ?readonly =" {{ readonly }} " ?disabled =" {{ disabled }} " name =" {{ name }} " data-sap-no-tab-ref/>
21
21
</div >
22
22
23
- {{ #if _label. text}}
24
- <ui5-label id =" {{ _id }} -label" class =" labelInRadioButton " for =" {{ _id }} " >{{ _label. text}} </ui5-label >
23
+ {{ #if text }}
24
+ <ui5-label id =" {{ _id }} -label" class =" ui5-radio-label " for =" {{ _id }} " ? wrap = " {{ wrap }} " >{{ text }} </ui5-label >
25
25
{{ /if }}
26
26
27
27
{{ #if hasValueState }}
Original file line number Diff line number Diff line change @@ -141,8 +141,17 @@ const metadata = {
141
141
type : String ,
142
142
} ,
143
143
144
- _label : {
145
- type : Object ,
144
+ /**
145
+ * Defines whether the <code>ui5-radiobutton</code> text wraps when there is not enough space.
146
+ * <br><br>
147
+ * <b>Note:</b> By default, the text truncates when there is not enough space.
148
+ *
149
+ * @type {boolean }
150
+ * @defaultvalue false
151
+ * @public
152
+ */
153
+ wrap : {
154
+ type : Boolean ,
146
155
} ,
147
156
} ,
148
157
events : /** @lends sap.ui.webcomponents.main.RadioButton.prototype */ {
@@ -209,7 +218,6 @@ class RadioButton extends UI5Element {
209
218
constructor ( ) {
210
219
super ( ) ;
211
220
212
- this . _label = { } ;
213
221
this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
214
222
}
215
223
@@ -239,17 +247,11 @@ class RadioButton extends UI5Element {
239
247
}
240
248
241
249
onBeforeRendering ( ) {
242
- this . syncLabel ( ) ;
243
250
this . syncGroup ( ) ;
244
251
245
252
this . _enableFormSupport ( ) ;
246
253
}
247
254
248
- syncLabel ( ) {
249
- this . _label = Object . assign ( { } , this . _label ) ;
250
- this . _label . text = this . text ;
251
- }
252
-
253
255
syncGroup ( ) {
254
256
const oldGroup = this . _name ;
255
257
const currentGroup = this . name ;
Original file line number Diff line number Diff line change 84
84
}
85
85
86
86
.ui5-radio-root {
87
+ height : 2.75rem ;
87
88
position : relative;
88
89
display : flex;
89
90
flex-wrap : nowrap;
112
113
}
113
114
114
115
/* Label */
115
- ui5-label .labelInRadioButton {
116
+ ui5-label .ui5-radio-label {
117
+ display : flex;
118
+ align-items : center;
116
119
width : calc (100% - 2.75rem );
117
120
padding-right : 1px ;
118
121
vertical-align : top;
119
- height : 2.75rem ;
120
- line-height : 2.75rem ;
121
122
cursor : default;
122
123
max-width : 100% ;
123
124
text-overflow : ellipsis;
124
125
overflow : hidden;
125
126
pointer-events : none;
126
127
}
127
128
129
+ : host ([wrap ][text ]) .ui5-radio-root {
130
+ height : auto;
131
+ }
132
+
133
+ : host ([wrap ][text ]) ui5-label .ui5-radio-label {
134
+ padding-bottom : .875rem ;
135
+ padding-top : .875rem ;
136
+ word-break : break-all;
137
+ }
138
+
128
139
/* SVG */
129
140
.ui5-radio-svg {
130
141
height : 2.75rem ;
@@ -145,6 +156,15 @@ ui5-label.labelInRadioButton {
145
156
height : 2rem ;
146
157
}
147
158
159
+ : host ([data-ui5-compact-size ][wrap ][text ]) .ui5-radio-root {
160
+ height : auto;
161
+ }
162
+
163
+ : host ([data-ui5-compact-size ][wrap ][text ]) ui5-label .ui5-radio-label {
164
+ padding-top : .5rem ;
165
+ padding-bottom : .5rem ;
166
+ }
167
+
148
168
: host ([data-ui5-compact-size ]) .ui5-radio-root : focus : before {
149
169
top : .375rem ;
150
170
bottom : .375rem ;
@@ -167,12 +187,9 @@ ui5-label.labelInRadioButton {
167
187
: host ([data-ui5-compact-size ]) .ui5-radio-root .ui5-radio-inner .ui5-radio-svg {
168
188
height : 2rem ;
169
189
width : 2rem ;
170
- line-height : 2rem ;
171
190
}
172
191
173
- : host ([data-ui5-compact-size ]) .ui5-radio-root ui5-label .labelInRadioButton {
174
- line-height : 2rem ;
175
- height : 2rem ;
192
+ : host ([data-ui5-compact-size ]) .ui5-radio-root ui5-label .ui5-radio-label {
176
193
width : calc (100% - 2rem + 1px );
177
194
}
178
195
Original file line number Diff line number Diff line change 25
25
</ style >
26
26
</ head >
27
27
28
- < body >
29
- < h1 > ui5-radiobutton</ h1 >
28
+ < body style =" background: var(--sapBackgroundColorDefault); " >
29
+ < ui5-title level =" H1 " > ui5-radiobutton</ ui5-title >
30
30
< ui5-radiobutton id ="rb1 "> </ ui5-radiobutton >
31
31
< ui5-radiobutton id ="rb2 " text ="Option B "> </ ui5-radiobutton >
32
- < ui5-radiobutton id ="rb3 " text ="Option C "> </ ui5-radiobutton >
32
+ < ui5-radiobutton id ="rb3 " wrap text ="Option C "> </ ui5-radiobutton >
33
33
< ui5-radiobutton id ="rb4 " disabled text ="Option D "> </ ui5-radiobutton >
34
+ < ui5-radiobutton id ="truncatingRb " text ="Long long long text that should truncate at some point "> > </ ui5-radiobutton >
35
+ < br />
36
+ < 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 >
34
37
35
38
< ui5-input id ="field "> </ ui5-input >
36
39
@@ -75,7 +78,7 @@ <h1>ui5-radiobutton</h1>
75
78
76
79
< p > *Params</ p >
77
80
< p >
78
- < ui5-label > - for compact use 'sap-ui-xx-wc-size-compact =true'</ ui5-label >
81
+ < ui5-label > - for compact use 'sap-ui-compactSize =true'</ ui5-label >
79
82
</ p >
80
83
< p >
81
84
< ui5-label > - for belize use 'sap-ui-theme=sap_belize'</ ui5-label >
Original file line number Diff line number Diff line change @@ -66,6 +66,18 @@ <h3>RadioButton in group - navigate via [UP/Right] and [DOWN/Left] arrow keys</h
66
66
</ xmp > </ pre >
67
67
</ section >
68
68
69
+ < section >
70
+ < h3 > RadioButton with Text Wrapping</ h3 >
71
+ < 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 >
74
+ </ div >
75
+ < 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 >
78
+ </ xmp > </ pre >
79
+ </ section >
80
+
69
81
< script >
70
82
radioGroup . addEventListener ( "select" , function ( e ) {
71
83
lblRadioGroup . innerHTML = e . target . text ;
Original file line number Diff line number Diff line change @@ -115,4 +115,19 @@ describe("RadioButton general interaction", () => {
115
115
assert . equal ( lblSelectedRadio . getHTML ( false ) , radioButtonToBeSelected . getProperty ( "text" ) , "The correct radio is selected" ) ;
116
116
} ) ;
117
117
118
+ it ( "tests truncating and wrapping" , ( ) => {
119
+ const truncatingRb = browser . $ ( "#truncatingRb" ) ;
120
+ const wrappingRb = browser . $ ( "#wrappingRb" ) ;
121
+ const RADIOBUTTON_DEFAULT_HEIGHT = 44 ;
122
+
123
+ const truncatingRbHeight = truncatingRb . getSize ( "height" ) ;
124
+ const wrappingRbHeight = wrappingRb . getSize ( "height" ) ;
125
+
126
+ assert . ok ( ! truncatingRb . getProperty ( "wrap" ) , "The text should not be wrapped." ) ;
127
+ assert . ok ( wrappingRb . getProperty ( "wrap" ) , "The text should be wrapped." ) ;
128
+
129
+ assert . strictEqual ( truncatingRbHeight , RADIOBUTTON_DEFAULT_HEIGHT , "The size of the radiobutton is : " + truncatingRbHeight ) ;
130
+ assert . ok ( wrappingRbHeight > RADIOBUTTON_DEFAULT_HEIGHT , "The size of the radiobutton is more than: " + RADIOBUTTON_DEFAULT_HEIGHT ) ;
131
+ } ) ;
132
+
118
133
} ) ;
You can’t perform that action at this time.
0 commit comments