Skip to content

[v4] Table.EditableCell accept textProps #279

@jeroenransijn

Description

@jeroenransijn

textProps needs to passed through properly.

render() {
  const {
    children,
    theme,
    size,
    disabled,
    placeholder,
    isSelectable,
    textProps,
    ...props
  } = this.props
  const { isEditing, value } = this.state

  return (
    <React.Fragment>
      <TextTableCell
        isSelectable={isSelectable && !disabled}
        innerRef={this.onMainRef}
        onClick={this.handleClick}
        onDoubleClick={this.handleDoubleClick}
        onKeyDown={this.handleKeyDown}
        size={size}
        cursor={disabled ? 'not-allowed' : 'default'}
        textProps={{
          size,
          opacity: disabled || (!children && placeholder) ? 0.5 : 1,
          ...textProps
        }}
        {...props}
      >
        {children ? children : placeholder}
      </TextTableCell>
      {isEditing && (
        <Portal>
          <Stack>
            {zIndex => (
              <EditableCellField
                zIndex={zIndex}
                getTargetRef={() => this.mainRef}
                value={value}
                onEscape={this.handleFieldEscape}
                onBlur={this.handleFieldBlur}
                onCancel={this.handleFieldCancel}
                size={size}
              />
            )}
          </Stack>
        </Portal>
      )}
    </React.Fragment>
  )
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions