Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Issue 680 - row and Bootstrap interactions #844

Merged
merged 58 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
81b7f68
change `row` class to `table-row` to avoid bootstrap collisions
Oct 27, 2020
e57e9ec
update .row -> .table-row in tests
Oct 28, 2020
86b0c43
row -> table-row in actual table..
Oct 28, 2020
ca91071
changelog
Oct 28, 2020
669e92c
Merge branch 'dev' into 680-bootstrap-row
Marc-Andre-Rivet Oct 28, 2020
08ef709
Add bootstrap to all visual tests - undo `table-` prefix fix temporarily
Oct 29, 2020
24e535b
Merge branch '680-bootstrap-row' of github.com:plotly/dash-table into…
Oct 29, 2020
1197b62
re apply `table-` prefix to fix `row` + override bootstrap 3.4.1 and …
Oct 29, 2020
170991b
make `table-row` more unique: `dt-table-container__row`
Oct 29, 2020
384330c
dt-table-container__row-0
Nov 4, 2020
c3e72d9
undo 'common' for bootstrap
Nov 5, 2020
ce75c45
!bootstrap
Nov 5, 2020
0426c84
!jquery
Nov 5, 2020
ec22f1c
Merge branch 'dev' into 680-bootstrap-row
Marc-Andre-Rivet Nov 5, 2020
a7d7465
CI: set appropriate percy token
Nov 5, 2020
2019e43
Merge branch '680-bootstrap-row' of github.com:plotly/dash-table into…
Nov 5, 2020
d2857e1
percy snapshot names can't contain `,`
Nov 5, 2020
e848edd
snapshots
Nov 5, 2020
0e53caa
conftest
Nov 5, 2020
5565825
percy
Nov 5, 2020
80fa30a
black
Nov 5, 2020
ea99a96
.
Nov 5, 2020
88701f2
undo
Nov 5, 2020
1d4641f
.
Nov 5, 2020
7ea3ccb
tmp_path
Nov 5, 2020
cad6e4f
dt-download
Nov 6, 2020
ab86080
tmpdir
Nov 6, 2020
b44ea17
PERCY_PARALLEL_TOTAL: -1
Nov 6, 2020
4791dc6
npx percy
Nov 6, 2020
9dc3058
percy-python-selenium?!
Nov 6, 2020
2bfe491
remove npx percy
Nov 6, 2020
8795792
+ @percy/agent
Nov 6, 2020
b97024d
puppets
Nov 6, 2020
cfd32ce
3.7-node
Nov 6, 2020
e6db08b
libnss3
Nov 6, 2020
be09a62
stretch
Nov 6, 2020
c10e1a8
puppet orb
Nov 6, 2020
7637f45
!orbs
Nov 6, 2020
b40a3cb
command
Nov 6, 2020
0201f5f
.
Nov 6, 2020
a090e2f
.
Nov 6, 2020
d5522e3
apt-get
Nov 6, 2020
ebc9f64
libgbm
Nov 6, 2020
08b1297
libgbm-dev
Nov 6, 2020
4c6d0fa
browsers
Nov 6, 2020
0eaf587
very long iframe delay
Nov 6, 2020
89e0692
no iframe
Nov 6, 2020
f1a5608
no externals?
Nov 6, 2020
67ef04d
percy v1
Nov 6, 2020
ba588ad
add back dbc theme
Nov 6, 2020
10f6779
undo fix: dt-table-container__row -> row
Nov 6, 2020
2d243d0
finalize
Nov 6, 2020
35298ab
percyfinalize
Nov 6, 2020
4ff7d7a
percy finalize
Nov 6, 2020
02a0f9b
redo `dt-table-container__row` fix
Nov 6, 2020
21220f1
clean up config
Nov 6, 2020
57a0b46
tests/selenium
Nov 6, 2020
227b79c
remove time.sleep(3)
Nov 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
version: 2
version: 2.1

jobs:
"server-test":
docker:
- image: circleci/python:3.7.6-node-browsers
environment:
PERCY_PARALLEL_TOTAL: -1
- image: cypress/base:10

steps:
- checkout
- run:
name: Inject Percy Environment variables
command: |
echo 'export PERCY_TOKEN="$PERCY_TOKEN_E2E"' >> $BASH_ENV

- restore_cache:
key: dep-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }}
- run:
Expand Down Expand Up @@ -44,6 +51,10 @@ jobs:
command: |
. venv/bin/activate
npm run test.server
- run:
name: 🦔 percy finalize
command: npx percy finalize --all
when: always


"standalone-test":
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- [#841](https://github.com/plotly/dash-table/pull/841)
- Fix prop-types regression causing console errors in browser devtools
- Fix syntax highlighting regression for Markdown cells
- [#844](https://github.com/plotly/dash-table/pull/844) Fix a bug where the table is using classes that are styled by Bootstrap
- [#842](https://github.com/plotly/dash-table/pull/842) Fix a regression introduced with [#722](https://github.com/plotly/dash-table/pull/722) causing the tooltips to be misaligned with respect to their parent cell and incompletely addressed in [#817](https://github.com/plotly/dash-table/pull/817)

### Added
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dash-bootstrap-components==0.10.7
pandas
preconditions
xlrd
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"postbuild": "es-check es5 dash_table/*.js",
"format": "run-s private::format.*",
"lint": "run-s private::lint.*",
"test.server": "pytest tests/selenium",
"test.server": "pytest --nopercyfinalize tests/selenium",
"test.standalone": "run-p --race private::host_js private::test.standalone",
"test.unit": "run-s private::test.python private::test.unit",
"test.visual": "build-storybook && percy-storybook",
Expand Down
2 changes: 1 addition & 1 deletion src/dash-table/components/ControlledTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ export default class ControlledTable extends PureComponent<
<div
key={`r${rowIndex}`}
ref={`r${rowIndex}`}
className={`row row-${rowIndex}`}
className={`dt-table-container__row dt-table-container__row-${rowIndex}`}
onScroll={this.onScroll}
>
{arrayMap3(
Expand Down
24 changes: 21 additions & 3 deletions src/dash-table/components/Table/Table.less
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@
flex-direction: row;
position: relative;

// This overrides Bootstrap 3.4.1 body styling
// https://github.com/twbs/bootstrap/blob/v3-dev/dist/css/bootstrap.css#L1087
// Also unapplies with the latest `in development` 5.0.0-alpha2 (https://github.com/twbs/bootstrap/blob/main/dist/css/bootstrap.css#L51)
line-height: initial;

// This overrides Chrome's default `font-size: medium;` which is causing performance issues
// with AutoInputResize sub-component in react-select
// https://github.com/JedWatson/react-input-autosize/blob/05b0f86a7f8b16de99c2b31296ff0d3307f15957/src/AutosizeInput.js#L58
Expand All @@ -234,6 +239,19 @@
}
}

input[type="radio"] {
// These override Bootstrap 3.4.1 type="radio" styling
// https://github.com/twbs/bootstrap/blob/v3-dev/dist/css/bootstrap.css#L2621
// This is not a problem with the latest `in development` 5.0.0-alpha2
margin: initial;
line-height: initial;
// These override Bootstrap 4.5.0 type="radio" styling
// https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L287
// This is not a problem with the latest `in development` 5.0.0-alpha2
box-sizing: initial;
padding: initial;
}

.dash-spreadsheet-inner {
box-sizing: border-box;
display: flex;
Expand Down Expand Up @@ -295,7 +313,7 @@
}

&:not(.dash-empty-11) {
.row-0 {
.dt-table-container__row-0 {
tr:last-of-type {
td, th {
border-bottom: none !important;
Expand Down Expand Up @@ -344,13 +362,13 @@
&.dash-virtualized {
overflow: hidden !important;

.row-0 {
.dt-table-container__row-0 {
display: flex;
flex: 0 0 auto;
flex-direction: row;
}

.row-1 {
.dt-table-container__row-1 {
display: flex;
flex-direction: row;
overflow: auto;
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/src/DashTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class DashTableHelper {
}

public toggleScroll(toggled: boolean) {
cy.get('.row-1').then($el => {
cy.get('.dt-table-container__row-1').then($el => {
$el[0].style.overflow = toggled ? '' : 'unset';
});
}
Expand Down
12 changes: 6 additions & 6 deletions tests/cypress/tests/standalone/scrolling_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ variants.forEach(([mode, flavors]) => {
DashTable.clickCellById(0, 'rows');
DashTable.getSelectedCells().should('have.length', 1);

cy.get('.row-1').scrollTo(0, 1000);
cy.get('.dt-table-container__row-1').scrollTo(0, 1000);
DashTable.getSelectedCells().should('have.length', 0);
});

it('keeps active cell', () => {
DashTable.clickCellById(0, 'rows');
DashTable.getActiveCell().should('have.length', 1);

cy.get('.row-1').scrollTo(0, 1000);
cy.get('.dt-table-container__row-1').scrollTo(0, 1000);
DashTable.getActiveCell().should('have.length', 0);

cy.get('.row-1').scrollTo(0, 0);
cy.get('.dt-table-container__row-1').scrollTo(0, 0);
DashTable.getActiveCell().should('have.length', 1);
});

Expand All @@ -45,10 +45,10 @@ variants.forEach(([mode, flavors]) => {

DashTable.getSelectedCells().should('have.length', 6);

cy.get('.row-1').scrollTo(0, 1000);
cy.get('.dt-table-container__row-1').scrollTo(0, 1000);
DashTable.getSelectedCells().should('have.length', 0);

cy.get('.row-1').scrollTo(0, 0);
cy.get('.dt-table-container__row-1').scrollTo(0, 0);
DashTable.getSelectedCells().should('have.length', 6);
});

Expand All @@ -57,7 +57,7 @@ variants.forEach(([mode, flavors]) => {
DashTable.clickCell(0, 0);
DashTable.toggleScroll(true);

cy.get('.row-1').scrollTo(0, 1000);
cy.get('.dt-table-container__row-1').scrollTo(0, 1000);
cy.wait(1000);

DashTable.clickCell(10, 1);
Expand Down
4 changes: 1 addition & 3 deletions tests/selenium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ def test(request, dash_thread_server, tmpdir):
remote_url=request.config.getoption("remote_url"),
headless=request.config.getoption("headless"),
options=request.config.hook.pytest_setup_options(),
download_path=tmpdir.mkdir("download").strpath,
percy_assets_root=request.config.getoption("percy_assets"),
download_path=tmpdir.mkdir("dt-download").strpath,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Table tests sometimes use dash_thread_server and dash_duo -- dash_duo specifically also creates a temporary folder, both fixtures clash and the tests end up throwing an error because the directory already exists. Pytest uses a py27 compatible object that does not expose exists_ok and hence the error can't otherwise be prevented.

percy_finalize=request.config.getoption("nopercyfinalize"),
percy_run=False,
) as dc:
yield dc
76 changes: 76 additions & 0 deletions tests/selenium/test_bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import dash
import pytest

import dash_bootstrap_components as dbc
import dash_html_components as html
from dash_table import DataTable

import pandas as pd

url = "https://github.com/plotly/datasets/raw/master/" "26k-consumer-complaints.csv"
rawDf = pd.read_csv(url)
df = rawDf.to_dict("rows")


def get_app(fixed_rows, fixed_columns, ops):
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])

props = dict(
id="table",
data=df[0:250],
columns=[
{"name": i, "id": i, "hideable": i == "Complaint ID"} for i in rawDf.columns
],
style_table=dict(height="500px", maxHeight="500px", overflow="auto"),
editable=True,
sort_action="native",
include_headers_on_copy_paste=True,
**fixed_rows,
**fixed_columns,
**ops
)

app.layout = html.Div([DataTable(**props)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially wanted this test to show a unmodified table + a another table in an iframe with bootstrap styles applied to offer some comparison point during review (e.g. only the bootstrap version changed vs. both) but the iframe content is never visible.


return app


@pytest.mark.parametrize(
"fixed_rows,fixed_rows_description",
[(dict(), "unfixed_rows"), (dict(fixed_rows=dict(headers=True)), "fixed_rows")],
)
@pytest.mark.parametrize(
"fixed_columns,fixed_columns_description",
[
(dict(), "unfixed_columns"),
(dict(fixed_columns=dict(headers=True)), "fixed_columns"),
],
)
@pytest.mark.parametrize(
"ops,ops_description",
[
(dict(), "ops: none"),
(dict(row_selectable="single", row_deletable=True), "ops: sinle+deletable"),
(dict(row_selectable="multi", row_deletable=True), "ops: multi+deletable"),
],
)
def test_tbbs001_display(
dash_thread_server,
dash_duo,
test,
fixed_rows,
fixed_columns,
ops,
fixed_rows_description,
fixed_columns_description,
ops_description,
):
test.start_server(get_app(fixed_rows, fixed_columns, ops))

test.table("table").is_ready()

test.percy_snapshot(
"DataTable Bootstrap side-effects with rows={} columns={} ops={}".format(
fixed_rows_description, fixed_columns_description, ops_description
)
)
6 changes: 4 additions & 2 deletions tests/selenium/test_scrolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def get_margin(test):

def get_scroll(test):
return test.driver.execute_script(
"return document.querySelector('#table .row-1').scrollLeft;"
"return document.querySelector('#table .dt-table-container__row-1').scrollLeft;"
)


def scroll_by(test, value):
test.driver.execute_script(
"document.querySelector('#table .row-1').scrollBy({}, 0);".format(value)
"document.querySelector('#table .dt-table-container__row-1').scrollBy({}, 0);".format(
value
)
)


Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Hideable.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { storiesOf } from '@storybook/react';
import DataTable from 'dash-table/dash/DataTable';

import dataset from './../../assets/gapminder.csv';

const result = parser.parse(dataset, { delimiter: ',', header: true });

const getColumns = () => R.addIndex(R.map)(
Expand Down