Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Change default styles [#193](https://github.com/plotly/dash-table/pull/193) [#150](https://github.com/plotly/dash-table/issues/150)
- prop `content_style` defaults to 'grow' instead of 'fit'
- prop `style_table` width nested property defaults to '100%' if not provided
- update default font-family from 'monospace' to `'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace`
- Change cell styling and filter display [#196](https://github.com/plotly/dash-table/pull/196) [#150](https://github.com/plotly/dash-table/issues/150)
- uneditable cells can be clicked & navigated, the mouse cursor is the default one
- filter inputs have a placeholder that is visible on hover and focus
- first filter input placeholder is always visible

## [3.1.0-rc18] - 2018-10-31
### Changed
Expand Down
4 changes: 2 additions & 2 deletions dash_table/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dash_table/demo.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/core/components/IsolatedInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { PureComponent } from 'react';
type Submit = (value: string | undefined) => void;

interface IProps {
placeholder?: string;
updateOnBlur?: boolean;
updateOnSubmit?: boolean;
stopPropagation?: boolean;
Expand Down Expand Up @@ -51,6 +52,7 @@ export default class IsolatedInput extends PureComponent<IProps, IState> {

render() {
const {
placeholder,
stopPropagation,
updateOnBlur,
updateOnSubmit
Expand All @@ -67,6 +69,7 @@ export default class IsolatedInput extends PureComponent<IProps, IState> {
type='text'
value={this.state.value || ''}
onChange={this.handleChange}
placeholder={placeholder}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding placeholder prop... wondering if we couldn't just compose off the dash-core-components input to get all the base prop types since the component works standalone. Might be an overkill, just thinking out loud here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's not a bad idea. How would that work though? Maybe if we were to redo core-components so that it's built more as a JS library, that both dash-renderer and other repo's like dash-table could use?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't really do that because components can't be properties right now in Dash. In the future, they could be. Otherwise, we'll need to copy over the properties one-by-one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is purely internal, I was thinking that just importing the component would work

{...props}
/>);
}
Expand Down
1 change: 0 additions & 1 deletion src/dash-table/components/CellFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default class CellFactory {
active_cell,
columns,
viewport.data,
editable,
selected_cells
);

Expand Down
2 changes: 1 addition & 1 deletion src/dash-table/components/Filter/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface IColumnFilterProps {
classes: string;
columnId: ColumnId;
isValid: boolean;
property: ColumnId;
setFilter: SetFilter;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property was redundant with columnId and unused

value?: string;
}
Expand Down Expand Up @@ -60,6 +59,7 @@ export default class ColumnFilter extends PureComponent<IColumnFilterProps, ICol
>
<IsolatedInput
value={value}
placeholder={`filter data...`}
stopPropagation={true}
submit={this.submit}
/>
Expand Down
1 change: 0 additions & 1 deletion src/dash-table/components/FilterFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export default class FilterFactory {
classes={`dash-filter column-${index}`}
columnId={column.id}
isValid={this.isFragmentValidOrNull(column.id)}
property={column.id}
setFilter={this.getEventHandler(this.onChange, column.id, this.ops, setFilter)}
value={this.ops.get(column.id.toString())}
/>);
Expand Down
33 changes: 22 additions & 11 deletions src/dash-table/components/Table/Table.less
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,29 @@
}
}

.dash-filter.invalid {
& when (@isListView = True) {
.inset-shadow(red, 0px, 0px, 0px, -1px);
.dash-filter {
input::placeholder {
color: inherit;
font-size: 0.8em;
padding-right: 5px;
}

& + .dash-filter {
&:not(:hover):not(:focus-within) {
input::placeholder {
color: transparent;
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only display the placeholder if (1) the filter is the first (not selected by & + .dash-filter), otherwise only show if hovered or focused

}

& when (@isListView = False) {
.inset-shadow(red, 1px, 1px, -1px, -1px);
&.invalid {
& when (@isListView = True) {
.inset-shadow(red, 0px, 0px, 0px, -1px);
}

& when (@isListView = False) {
.inset-shadow(red, 1px, 1px, -1px, -1px);
}
}
}
}
Expand Down Expand Up @@ -384,7 +400,7 @@
.dash-spreadsheet-inner table {
border-collapse: collapse;

font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
font-family: monospace;
--accent: hotpink;
--border: lightgrey;
--text-color: rgb(60, 60, 60);
Expand Down Expand Up @@ -512,11 +528,6 @@
color: var(--accent);
}

.cell--uneditable,
.cell--uneditable input {
cursor: not-allowed;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the cursor style on readonly cells

.expanded-row {
box-shadow: inset 2px 0px 0px 0px var(--accent),
inset -1px 0px 0px 0px var(--border);
Expand Down
8 changes: 2 additions & 6 deletions src/dash-table/derived/cell/wrappers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Cell from 'dash-table/components/Cell';
import isActiveCell from 'dash-table/derived/cell/isActive';
import isSelectedCell from 'dash-table/derived/cell/isSelected';
import memoizerCache from 'core/memoizerCache';
import isEditable from './isEditable';

type Key = [number, number];
type ElementCacheFn = (
Expand All @@ -23,7 +22,6 @@ function getter(
activeCell: ActiveCell,
columns: VisibleColumns,
data: Data,
editable: boolean,
selectedCells: SelectedCells
): JSX.Element[][] {
return R.addIndex<Datum, JSX.Element[]>(R.map)(
Expand All @@ -36,7 +34,6 @@ function getter(
'dash-cell' +
` column-${columnIndex}` +
(active ? ' focused' : '') +
(!isEditable(editable, column.editable) ? ' cell--uneditable' : '') +

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cell-uneditable is now useless -- removing it.. the cell can be customized through the style_cell prop, there's no need for this css selector

(selected ? ' cell--selected' : '') +
(column.type === ColumnType.Dropdown ? ' dropdown' : '');

Expand All @@ -51,9 +48,8 @@ function getter(
function decorator(_id: string): ((
activeCell: ActiveCell,
columns: VisibleColumns,
columnConditionalStyle: any,
columnStaticStyle: any,
data: Data
data: Data,
selectedCells: SelectedCells

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing error here that went unnoticed because of the 'any'

) => JSX.Element[][]) {
const elementCache = memoizerCache<Key, [boolean, string, number, ColumnId], JSX.Element>(
(active: boolean, classes: string, columnIndex: number, columnId: ColumnId) => (<Cell
Expand Down
40 changes: 40 additions & 0 deletions tests/visual/percy-storybook/Filters.percy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as R from 'ramda';
import React from 'react';
import { storiesOf } from '@storybook/react';
import random from 'core/math/random';
import DataTable from 'dash-table/DataTable';

const setProps = () => { };

const data = (() => {
const r = random(1);

return R.range(0, 5).map(() => (
['a', 'b', 'c'].reduce((obj: any, key) => {
obj[key] = Math.floor(r() * 1000);
return obj;
}, {})
));
})();

let props = {
setProps,
id: 'table',
data: data,
filtering: true,
style_cell: {
width: 100,
min_width: 100,
max_width: 100
}
};

storiesOf('DashTable/Filtering', module)
.add('with a single column', () => (<DataTable
{...props}
columns={['a'].map(id => ({ id: id, name: id.toUpperCase() }))}
/>))
.add('with multiple columns', () => (<DataTable
{...props}
columns={['a', 'b', 'c'].map(id => ({ id: id, name: id.toUpperCase() }))}
/>));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two basic visual tests that make sure the first filter displays the placeholder and that the others do not.