File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed
src/render/components/form-fields
test/spec/render/components/form-fields Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -346,5 +346,9 @@ function serializeCellData(cellData) {
346346 return JSON . stringify ( cellData ) ;
347347 }
348348
349- return `${ cellData || '' } ` ;
349+ if ( cellData === null || cellData === undefined ) {
350+ return '' ;
351+ }
352+
353+ return `${ cellData } ` ;
350354}
Original file line number Diff line number Diff line change @@ -203,6 +203,55 @@ describe('Table', function () {
203203 expect ( secondRow . querySelectorAll ( '.fjs-table-td' ) [ 2 ] . textContent ) . to . eql ( '' ) ;
204204 } ) ;
205205
206+ it ( 'should handle falsy values in table cells' , function ( ) {
207+ // when
208+ const DATA = [
209+ {
210+ id : 0 ,
211+ name : false ,
212+ date : '' ,
213+ } ,
214+ {
215+ id : null ,
216+ name : undefined ,
217+ date : 'valid' ,
218+ } ,
219+ ] ;
220+
221+ const { container } = createTable ( {
222+ initialData : {
223+ data : DATA ,
224+ } ,
225+ field : {
226+ ...defaultField ,
227+ columns : MOCK_COLUMNS ,
228+ dataSource : '=data' ,
229+ } ,
230+ services : {
231+ expressionLanguage : {
232+ isExpression : ( ) => true ,
233+ evaluate : ( ) => DATA ,
234+ } ,
235+ } ,
236+ } ) ;
237+
238+ // then
239+ const bodyRows = container . querySelectorAll ( '.fjs-table-body .fjs-table-tr' ) ;
240+ expect ( bodyRows ) . to . have . length ( 2 ) ;
241+
242+ const [ firstRow , secondRow ] = bodyRows ;
243+
244+ expect ( firstRow . querySelectorAll ( '.fjs-table-td' ) ) . to . have . length ( 3 ) ;
245+ expect ( firstRow . querySelectorAll ( '.fjs-table-td' ) [ 0 ] . textContent ) . to . eql ( '0' ) ;
246+ expect ( firstRow . querySelectorAll ( '.fjs-table-td' ) [ 1 ] . textContent ) . to . eql ( 'false' ) ;
247+ expect ( firstRow . querySelectorAll ( '.fjs-table-td' ) [ 2 ] . textContent ) . to . eql ( '' ) ;
248+
249+ expect ( secondRow . querySelectorAll ( '.fjs-table-td' ) ) . to . have . length ( 3 ) ;
250+ expect ( secondRow . querySelectorAll ( '.fjs-table-td' ) [ 0 ] . textContent ) . to . eql ( '' ) ;
251+ expect ( secondRow . querySelectorAll ( '.fjs-table-td' ) [ 1 ] . textContent ) . to . eql ( '' ) ;
252+ expect ( secondRow . querySelectorAll ( '.fjs-table-td' ) [ 2 ] . textContent ) . to . eql ( 'valid' ) ;
253+ } ) ;
254+
206255 it ( 'should have pagination' , async function ( ) {
207256 // when
208257 const DATA = [
You can’t perform that action at this time.
0 commit comments