React-table: Column header with blue outline after clicking for sorting

Created on 14 Dec 2017  路  11Comments  路  Source: tannerlinsley/react-table

What version of React-Table are you using?

Your bug may already be fixed in the latest release. Run yarn upgrade react-table!
6.7.5

What bug are you experiencing, or what feature are you proposing?

As described in Title.
Refer to description by @gary-menzel in https://github.com/react-tools/react-table/issues/682

Use https://codesandbox.io/s/X6npLXPRW (by clicking the "Fork" button) to reproduce the issue.

https://codesandbox.io/s/5knzrn8qmk

What are the steps to reproduce the issue?

  1. npm install -g create-react-app
  2. Add '[email protected]' to package.json.
  3. replace src/App.js with following code
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import ReactTable from 'react-table';
import 'react-table/react-table.css';

class App extends Component {
  constructor() {
    super();
  }
  render() {
    const data = [
            {
                "location":"01-01",
                "amount":150
            },
            {
                "location":"01-02",
                "amount":3000
            },
            {
                "location":"01-03",
                "amount":1201
            }
    ];

    const columns = [
      {
        Header: "Location",
        accessor: "location"
      },
      {
        Header: "Amount",
        accessor: "amount",
        Cell: props => <span className='number'>{props.value}</span>
      }
    ];

    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to React</h1>
        </header>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
        <ReactTable
          data={data}
          columns={columns}
          classsName='-striped -highlight'
        />
      </div>
    );
  }
}

export default App;
  1. npm start.
  2. Click any title of headers, and it shows

image

High bug

Most helpful comment

Add this to your CSS:

.ReactTable .rt-thead [role="columnheader"] {
outline: 0;
}

All 11 comments

Thanks for that - checking in some changes against this issue now. Not sure how quickly it will make it into a release (but I have notified the owner).

Yes noticed it too, the outline also wraps the column-resizer so it looks weird

I think the outline is fine, just fixing the boundaries will be good (by moving resize handles out of focusable header buttons)

The focus issue is a bug that has a PR in waiting to get released.

I've recently started using React Table and noticed that this bug is still occurring. Using the Code Sandbox link referenced above (https://codesandbox.io/s/5knzrn8qmk) I updated the react-table dependency to 6.8.0 and the blue outline is still there.

I've create a PR with a fix (see #881)

Please see my comment on the PR.

One thing that works for me is using the onSortedChange property, overriding it to blur the document's active element.

<ReactTable
    ...
    onSortedChange={(c, s) => { document.activeElement.blur() }}
    ...
    />

The blue outline flickers so it isn't eliminated completely, but at least it doesn't hang around and be a distracting nuisance for people who do not need to track focus.

Hope this helps others!

Any news on that PR? I still have the Issue in 6.8.2

Add this to your CSS:

.ReactTable .rt-thead [role="columnheader"] {
outline: 0;
}

I updated react-table which didn't work and I couldn't figure out how to add Mikkel-Vagn's css in without hardcoding it into the module files. This works for me though.

getTheadThProps={() => { return { style: { outline: 0, } }; }}

Following on from @cedricholz comment, incase this is of any use to anyone - I had grouped table headers, so used the getTheadGroupThProps function also:

getTheadThProps={() => { return { style: { outline: 0, } }; }}
getTheadGroupThProps = {() => { return { style: { outline: 0, } }; }}

.ReactTable .rt-resizer{ display:inline-block; position:absolute; width:3px; top:0; bottom:0; right:-1px; cursor:col-resize; z-index:10 }
did the trick. it reduces the size of the table column resizer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krishna-shenll picture krishna-shenll  路  3Comments

esetnik picture esetnik  路  3Comments

monarajhans picture monarajhans  路  3Comments

ocalde picture ocalde  路  3Comments

DaveyEdwards picture DaveyEdwards  路  3Comments