Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header clickable even if no data #699

Closed
wants to merge 6 commits into from

Conversation

mathieupetrini
Copy link

Related to #612

@mathieupetrini
Copy link
Author

@jbetancur Can you take a look to this PR ?

@jbetancur
Copy link
Owner

@mathieupetrini thanks for the PR. Sorry for the delay as I have been quite busy. So are you proposing to remove disabling the header and just disable to individual TableCols? Curious if there a specific use case that led to this?

@jbetancur jbetancur self-assigned this Nov 11, 2020
@mathieupetrini
Copy link
Author

The goal of this PR is to remove disabling the header when there is any data.

The purpose is to keep filter include in header available to be changed.

@jbetancur jbetancur added the enhancement New feature or request label Nov 17, 2020
Copy link
Owner

@jbetancur jbetancur left a comment

Choose a reason for hiding this comment

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

A few comments on naming. Also, we also need a snapshot test for this case scenario. Give the test a shot otherwise I can add it later.

src/DataTable/DataTable.js Show resolved Hide resolved
src/DataTable/DataTable.js Outdated Show resolved Hide resolved
src/DataTable/TableCol.js Outdated Show resolved Hide resolved
src/DataTable/TableCol.js Show resolved Hide resolved
Need to make test snapshot
@codecov
Copy link

codecov bot commented Nov 18, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@a3998ae). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #699   +/-   ##
=========================================
  Coverage          ?   99.38%           
=========================================
  Files             ?       43           
  Lines             ?      489           
  Branches          ?      137           
=========================================
  Hits              ?      486           
  Misses            ?        3           
  Partials          ?        0           
Impacted Files Coverage Δ
src/DataTable/DataTable.js 100.00% <ø> (ø)
src/DataTable/TableHeadRow.js 100.00% <ø> (ø)
src/DataTable/TableCol.js 100.00% <100.00%> (ø)
src/DataTable/Pagination.js 100.00% <0.00%> (ø)
src/DataTable/ExpanderRow.js 100.00% <0.00%> (ø)
src/icons/Left.js 100.00% <0.00%> (ø)
src/DataTable/styles.js 100.00% <0.00%> (ø)
src/icons/FirstPage.js 100.00% <0.00%> (ø)
src/DataTable/TableColExpander.js 100.00% <0.00%> (ø)
src/DataTable/TableHead.js 100.00% <0.00%> (ø)
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3998ae...a5aa1d8. Read the comment docs.

@mathieupetrini
Copy link
Author

mathieupetrini commented Nov 18, 2020

I had a snapshot test. I'm not sure about is quality if you can give a look.

Thanks for reviewing

src/DataTable/TableHeadRow.js Outdated Show resolved Hide resolved

const mock = dataMock({
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
name: (<div id="testColName" onClick={functionHadToBeClicked}>Test</div>),
Copy link
Owner

Choose a reason for hiding this comment

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

Why is the name block is needed or funcitonHadtoBeClicked? You just need to mock someone attempting to click the cell when data is 0 or prrogresspending is true

Copy link
Owner

@jbetancur jbetancur Nov 18, 2020

Choose a reason for hiding this comment

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

these are the tests you need

  test('should not call onSort if progressPending true', () => {
    const onSortMock = jest.fn();
    const mock = dataMock({ sortable: true });
    const { container } = render(
      <DataTable
        data={mock.data}
        columns={mock.columns}
        onSort={onSortMock}
        persistTableHead
        progressPending
      />,
    );

    fireEvent.click(container.querySelector('div[id="column-some.name"]'));

    expect(onSortMock).not.toBeCalled();
  });

and

  test('should not call onSort if data is empty []', () => {
    const onSortMock = jest.fn();
    const mock = dataMock({ sortable: true });
    const { container } = render(
      <DataTable
        data={[]}
        columns={mock.columns}
        onSort={onSortMock}
        persistTableHead
      />,
    );

    fireEvent.click(container.querySelector('div[id="column-some.name"]'));

    expect(onSortMock).not.toBeCalled();
  });

Copy link
Author

Choose a reason for hiding this comment

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

No, i even want to be able to click on div or focus input in TableCol.

For example, here i cannot click on select under "Status" ...
image

@jbetancur jbetancur added the next The next version (beta) label Dec 29, 2020
@jbetancur jbetancur added this to the RDT Next milestone Dec 29, 2020
@jbetancur jbetancur added this to To do in RDT Next 7 Dec 29, 2020
@jbetancur jbetancur removed this from To do in RDT Next 7 May 1, 2021
@jonathanxlee
Copy link

Is there any update on this feature. This would be very helpful.

@mounicagdv
Copy link

how to make the columns header clickable for sorting

@abaum-augu
Copy link

abaum-augu commented Feb 2, 2023

Any updates on this? @jbetancur if you still interested on a use case for this, we are developing a multi table component to which you can pass single tables as child.

<MultiTable>
  <Table/>
  <Table/>
</MultiTable>

The Multi table has a header that controls sorting for all of the child tables. That header is actually an empty data table. So in this case the sorting buttons are disabled, therefore can't sort the children tables data.

@jbetancur
Copy link
Owner

/inactive

@jbetancur jbetancur closed this Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next The next version (beta)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants