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

Specify widths on table columns to support long field names #17344

Merged
merged 2 commits into from
Mar 26, 2018

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Mar 22, 2018

Fixes #17199

Manually specify table column widths to avoid long field names overlapping other columns.

screen shot 2018-03-22 at 10 16 31 am

@chrisronline
Copy link
Contributor

@elastic/kibana-design Is it possible to solve this through CSS on the EUI side? It feels clunky to have to specify this manually, but if there is no better way, it's probably fine

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

This solution is a little brittle because we'll still get overlapping column content if the field name is long enough or if the screen is narrow enough.

I think @jen-huang's suggestion of adding word-break: break-word is a great solution. Here's the layout I was able to achieve with some tweaks:

image

Here's how I edited the styles:

image

Here's the change I made to the code:

  renderFieldName(name, isTimeField) {
    return (
      <Fragment>
        {name}
        {true ? (
          <Fragment>
            &nbsp;
            <EuiToolTip content="This field represents the time that events occurred.">
              <EuiIcon type="clock" color="primary" />
            </EuiToolTip>
          </Fragment>
        ) : ''}
      </Fragment>
    );
  }

/* ... */

    const columns = [
      {
        field: 'displayName',
        name: 'Name',
        dataType: 'string',
        sortable: true,
        'data-test-subj': 'indexedFieldName',
        render: (value) => {
          return this.renderFieldName(value, indexPattern.timeFieldName === value);
        },
        width: '38%',
      },

@cjcenizal
Copy link
Contributor

cjcenizal commented Mar 22, 2018

I adjusted the code a bit to get a better flow, and also fixed a mistake I made with data-test-subj in my original snippet:

image

  renderFieldName(name, isTimeField) {
    return (
      <span data-test-subj="indexedFieldName">
        {name}
        {true ? (
          <span>
            &nbsp;
            <EuiToolTip content="This field represents the time that events occurred.">
              <EuiIcon type="clock" color="primary" />
            </EuiToolTip>
          </span>
        ) : ''}
      </span>
    );
  }

@jen-huang
Copy link
Contributor Author

@chrisronline @cjcenizal

PR updated to use EUI 0.0.34 which includes word-break: break-word; on the tables, so if the field name is longer than the column width, it will just wrap. I'm keeping the 38% width declaration since by default, the column renders narrowly (will wrap too soon).

Also simplified the rendering functions as suggested and now passing data-test-subj into the column configuration instead of manual attributes.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Looks great!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM!

@jen-huang jen-huang merged commit e285627 into elastic:master Mar 26, 2018
jen-huang added a commit to jen-huang/kibana that referenced this pull request Mar 26, 2018
…17344)

* Specify widths on table columns to support long field names
jen-huang added a commit that referenced this pull request Mar 26, 2018
…17395)

* Specify widths on table columns to support long field names
@jen-huang jen-huang deleted the fix/table-column-widths branch June 5, 2019 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants