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

[Table] SelectField in Table getting cut off #2186

Closed
celiao opened this issue Nov 16, 2015 · 4 comments
Closed

[Table] SelectField in Table getting cut off #2186

celiao opened this issue Nov 16, 2015 · 4 comments
Labels
component: select This is the name of the generic UI component, not the React module! component: table This is the name of the generic UI component, not the React module!

Comments

@celiao
Copy link

celiao commented Nov 16, 2015

I would like to place a SelectField component in a Table cell, but the SelectField menu is getting truncated to the height of the row. How can the full menu be displayed?

@celiao
Copy link
Author

celiao commented Nov 16, 2015

image

Also, when I select a menu item, the entire row is being (de)selected.

@alitaheri
Copy link
Member

First, give your table enough height, then set your TableRowColumn's styles with these:

{ whiteSpace: 'normal'
, overflow: 'visible'
}

For the record, there some work being done to address this issue for all components. see #2043.

@celiao
Copy link
Author

celiao commented Nov 16, 2015

Works great. Thanks for your speedy reply.

I used the approach presented in #1702 to get rid of the checkboxes, and <Table selectable={false}> to disable rows from being selected.

It would be nice to be able to prevent the SelectField from selecting the row.

@celiao celiao closed this as completed Nov 16, 2015
@alitaheri
Copy link
Member

@celiao You're welcome ^^

It would be nice to be able to prevent the SelectField from selecting the row.

It's possible, TableRow adds handlers to it's children. you can make a Higher Order Component and pass down only those you want, like onHover. actually it's a lot better this way, you can make a TableSelectField that abstracts away all the complexity. Here is what I did to achieve the same effect:

export default class TableSelectField extends React.Component {

    render() {

        const styles = {
            cell: {
                paddingBottom: 0,
                paddingRight: 0,
                whiteSpace: 'normal',
                overflow: 'visible',
            },
            field: {
                fontSize,
                width: '100%',
                height: '100%',
            },
            label: {
                padding: 0,
                top: '50%',
                transform: 'translate(0, -50%)',
            },
            icon: {
                top: '50%',
                transform: 'translate(0, -50%)',
            },
            underline: {
                display: 'none',
            },
            menu: {
                width: '100%',
            },
        }

        return (
            <TableRowColumn
                onClick={this.props.disabled ? this.props.onClick : () => { } }
                hoverable={this.props.hoverable}
                onHover={this.props.onHover}
                onHoverExit={this.props.onHoverExit}
                style={assign(styles.cell, this.props.style) }>
              <DropDownMenu
                  value={this.props.selectedItemId}
                  style={styles.field}
                  labelStyle={styles.label}
                  iconStyle={styles.icon}
                  underlineStyle={styles.underline}
                  menuItemStyle={styles.menu}
                  autoWidth={false}
                  disabled={this.props.disabled}
                  onChange={this.props.onChange}
                  menuItems={this.props.items}/>
                </TableRowColumn>
        )
    }
}

To use this you can simply replace TableRowColumn with TableSelectField.

<Table height={'300px'} selectable={true}>
  <TableHeader adjustForCheckbox={false} displaySelectAll={false}>
    <TableRow>
      ...
    </TableRow>
  </TableHeader>
  <TableBody displayRowCheckbox={false} showRowHover={false} stripedRows={true}>
    <TableRow>
      <TableSelectField .../>
    </TableRow>
  </TableBody>
</Table>

@zannager zannager added component: select This is the name of the generic UI component, not the React module! component: table This is the name of the generic UI component, not the React module! labels Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! component: table This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants