From 1076008cdbfeb4d33d3e0355b117ddbb15d39253 Mon Sep 17 00:00:00 2001 From: dmt0 Date: Thu, 19 Sep 2019 14:49:07 -0400 Subject: [PATCH 1/2] Ensure booleans are showing --- src/dash-table/components/CellLabel/index.tsx | 4 +- src/dash-table/components/Table/props.ts | 2 +- src/dash-table/dash/DataTable.js | 9 ++- tests/visual/percy-storybook/Types.percy.tsx | 72 +++++++++++++++++++ 4 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 tests/visual/percy-storybook/Types.percy.tsx diff --git a/src/dash-table/components/CellLabel/index.tsx b/src/dash-table/components/CellLabel/index.tsx index 488204913..0c43ef44b 100644 --- a/src/dash-table/components/CellLabel/index.tsx +++ b/src/dash-table/components/CellLabel/index.tsx @@ -17,7 +17,9 @@ export default class CellLabel extends PureComponent { return (
- {value} + {typeof value === 'boolean' ? + value.toString() : + value}
); } } \ No newline at end of file diff --git a/src/dash-table/components/Table/props.ts b/src/dash-table/components/Table/props.ts index b66829651..94538ca00 100644 --- a/src/dash-table/components/Table/props.ts +++ b/src/dash-table/components/Table/props.ts @@ -185,7 +185,7 @@ interface IDatumObject { export interface IDropdownValue { label: string; - value: string | number; + value: string | number | boolean; } export interface IDropdown { diff --git a/src/dash-table/dash/DataTable.js b/src/dash-table/dash/DataTable.js index 3cc026f23..f59e2480f 100644 --- a/src/dash-table/dash/DataTable.js +++ b/src/dash-table/dash/DataTable.js @@ -741,7 +741,8 @@ export const propTypes = { label: PropTypes.string.isRequired, value: PropTypes.oneOfType([ PropTypes.number, - PropTypes.string + PropTypes.string, + PropTypes.bool ]).isRequired })).isRequired })), @@ -763,7 +764,8 @@ export const propTypes = { label: PropTypes.string.isRequired, value: PropTypes.oneOfType([ PropTypes.number, - PropTypes.string + PropTypes.string, + PropTypes.bool ]).isRequired })).isRequired })), @@ -781,7 +783,8 @@ export const propTypes = { label: PropTypes.string.isRequired, value: PropTypes.oneOfType([ PropTypes.number, - PropTypes.string + PropTypes.string, + PropTypes.bool ]).isRequired })).isRequired }) diff --git a/tests/visual/percy-storybook/Types.percy.tsx b/tests/visual/percy-storybook/Types.percy.tsx new file mode 100644 index 000000000..83d635ffb --- /dev/null +++ b/tests/visual/percy-storybook/Types.percy.tsx @@ -0,0 +1,72 @@ +import * as R from 'ramda'; +import React from 'react'; +import { storiesOf } from '@storybook/react'; +import DataTable from 'dash-table/dash/DataTable'; + +const setProps = () => { }; +const columns: { name: string[]; id: string; presentation?: string }[] = [ + { name: ['String'], id: 'string' }, + { name: ['Number'], id: 'number' }, + { name: ['Date'], id: 'date' }, + { name: ['Boolean'], id: 'boolean' }, + { name: ['Any'], id: 'any' }, +]; + +const columns_dd = columns.map(i => ({...i, presentation: 'dropdown'})); + +storiesOf('DashTable/Types', module) + .add('types input', () => ()) + .add('types dropdown', () => ( ({ label: `label: ${i}`, value: i }), + ['Montreal', 'Vermont', 'New York City', 'Boston'] + ) + }, + number: { + options: R.map( + i => ({ label: `label: ${i}`, value: i }), + [1, 2, 3, 4] + ) + }, + date: { + options: R.map( + i => ({ label: `label: ${i}`, value: i }), + ['2015-01-01', '2015-10-24', '2016-05-10', '2017-11-11'] + ) + }, + boolean: { + options: R.map( + i => ({ label: `label: ${i}`, value: i }), + [true, false] + ) + }, + any: { + options: R.map( + i => ({ label: `label: ${i}`, value: i }), + ['Montreal', 1, '2015-01-01', true] + ) + } + }} + />)); \ No newline at end of file From 51674a11a0334f5e24650e9c7e8fc6b2ff034193 Mon Sep 17 00:00:00 2001 From: dmt0 Date: Thu, 19 Sep 2019 14:51:47 -0400 Subject: [PATCH 2/2] Changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56af8a9ab..eff0a8343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,9 @@ multi-line & ellipsis with `style_data` and other style props. [#583](https://github.com/plotly/dash-table/issues/583) - Fix regression when editing the content of a cell in a scrolled virtualized table +[#539](https://github.com/plotly/dash-table/issues/539) +- Fix bug where boolean values are not showing up in the table + ## [4.2.0] - 2019-08-27 ### Added [#317](https://github.com/plotly/dash-table/issues/317)