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] feat(EditableCell2): new placeholder prop #5421

Merged
merged 7 commits into from
Jul 20, 2022
Merged

[table] feat(EditableCell2): new placeholder prop #5421

merged 7 commits into from
Jul 20, 2022

Conversation

ayxliu19
Copy link
Contributor

@ayxliu19 ayxliu19 commented Jul 8, 2022

Fixes #5083

Changes proposed in this pull request:

Added a placeholder feature that can be inputted to the editableTextProps field in EditableCell2. The placeholder shows the placeholder string if the cell is blank.

Another Design:
Since this approach uses the editableTextProps field, it is awkward calling it outside of the editable text field that is rendered when isEditing is true in

A better approach may be to create a new placeholder field in the EditableCell2 class and use that instead of calling the one that is in editableTextProps.

Screenshot

Example:

      <EditableCell2
          value={value == null ? "" : value}
          intent={this.state.sparseCellIntent[dataKey]}
          onCancel={this.cellValidator(rowIndex, columnIndex)}
          onChange={this.cellValidator(rowIndex, columnIndex)}
          onConfirm={this.cellSetter(rowIndex, columnIndex)}
          editableTextProps={{ placeholder: "42" }}
      />

Screen Shot 2022-07-08 at 5 08 32 PM

Alex Liu and others added 2 commits July 8, 2022 13:07
Now placeholders can be used in editable cell2 objects
@ayxliu19 ayxliu19 requested review from adidahiya and gluxon July 8, 2022 21:16
yarn.lock Outdated
@@ -5255,7 +5255,7 @@ first-mate@^7.0.2:
event-kit "^2.2.0"
fs-plus "^3.0.0"
grim "^2.0.1"
oniguruma "7.2.1"
oniguruma "7.2.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

This was fixed in #5407. Just merge in develop

@ayxliu19 ayxliu19 changed the title Al/placeholder Fix for placeholder issue palantir#5083 Jul 12, 2022
@ayxliu19 ayxliu19 changed the title Fix for placeholder issue palantir#5083 Fix for placeholder issue in Tables. Now placeholders can be used in editable cell2 objects. Jul 12, 2022
@ayxliu19 ayxliu19 changed the title Fix for placeholder issue in Tables. Now placeholders can be used in editable cell2 objects. Support placeholder in EditableCell2 Jul 12, 2022
@adidahiya
Copy link
Contributor

Hey @ayxliu19, please revert your changes to yarn.lock and merge in develop to this branch. In the future, if you commit code to Blueprint which edits the lockfile, you'll need to remember to change your NPM config to avoid pointing to our internal NPM mirror while working in this repo. I usually do this by running npm config list to find where the registry config is being set, and then editing that file to comment out the registry line. This will reset NPM to use the default registry at https://registry.yarnpkg.com.

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

I think your intuition is right, that the editableTextProps={ placeholder } API feels a bit weird, especially since you've implemented it in a way that the placeholder is rendered even when <EditableText> is not present. It would be better to add a placeholder prop to <EditableCell2>, and mention that this new prop overrides editableTextProps.placeholder in its documentation.

@@ -64,3 +64,7 @@
right: 0;
top: 0;
}

.#{$ns}-table-cell-text-placeholder {
color: $input-placeholder-color;
Copy link
Contributor

Choose a reason for hiding this comment

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

we'll need to add dark theme styles as well, using $pt-dark-text-color-muted

@@ -33,6 +33,7 @@ Color aliases

$table-background-color: $light-gray5 !default;
$dark-table-background-color: $dark-gray4 !default;
$input-placeholder-color: $pt-text-color-muted !default;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need this variable, especially since it's the same name as another (non-public) variable in core/src/components/forms. You can just reference the $pt-text-color-muted and $pt-dark-text-color-muted variables directly where you need the colors.

@ayxliu19
Copy link
Contributor Author

ayxliu19 commented Jul 19, 2022

Hi @adidahiya . Thank you for the feedback. I have made the changes and recompiled the documentation, but it seems like currently EditableCell2Props are not being displayed in the Blueprint documentation page: https://blueprintjs.com/docs/#table/api.editablecell

Would you like me to incorporate the same changes to EditableCell1 so that the changes are reflected in the documentation?

Added dark theme css style for placeholder
Co-authored-by: Michael Wu <michael-yx-wu@users.noreply.github.com>
Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

@ayxliu19 good point about EditableCell2 not being shown in the docs -- I will fix that in a separate PR. No need to block on that for now, though.

});

cellContents = <div className={textClasses}>{savedValue}</div>;
cellContents = <div className={textClasses}>{hasValue ? savedValue : this.props.placeholder}</div>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good but I think we need to bring back the change to cellContents a few lines above here... <EditableText placeholder={this.props.placeholder}> should be set on L168, as suggested in the documentation of the new prop you just added.

@adidahiya
Copy link
Contributor

I'm adding EditableCell2Props to the docs in this PR: #5449

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

nice, thanks @ayxliu19 👍🏽

@adidahiya adidahiya changed the title Support placeholder in EditableCell2 [table] feat(EditableCell2): new placeholder prop Jul 20, 2022
@adidahiya adidahiya merged commit 2cc9949 into palantir:develop Jul 20, 2022
@ayxliu19 ayxliu19 deleted the AL/Placeholder branch July 20, 2022 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EditableCell2.editableTextProps.placeholder is not working
3 participants