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

Custom attributes for <EditableText /> underlying textarea #7333

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

rallelind
Copy link

Fixes #6916

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Reviewers should focus on:

I added the ability to pass custom attributes to the underlying text area element. It was not clear to me if this should also be added for the underlying input and if so should that have a seperate prop? Or would we just use the same prop for the two.

Furthermore, this is the first time i try contributing to an open source project, would love feedback if any!

Screenshot

@palantirtech
Copy link
Member

Thanks for your interest in palantir/blueprint, @rallelind! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@rallelind rallelind closed this Mar 10, 2025
@rallelind rallelind reopened this Mar 10, 2025
@ashleighp13 ashleighp13 requested a review from jscheiny March 10, 2025 18:11
@rallelind
Copy link
Author

Thanks for your interest in palantir/blueprint, @rallelind! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

I did sign this, but it does not seem like the PR updated. Do i need to do anything?

* `multiline={true}`. This allows you to specify additional attributes like
* `aria-` attributes, `data-` attributes, etc.
*/
customTextareaAttributes?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's plausible that a consumer of this component might want to add custom attributes even when the component isn't multiline. Could we extend this prop to cover both cases? Something like:

Suggested change
customTextareaAttributes?: {
customInputAttributes?: {
return multiline ? (
    <textarea ref={this.refHandlers.input} {...props} {...customInputAttributes} />
) : (
    <input ref={this.refHandlers.input} type={type} {...props} {...customInputAttributes} />
);

We should also consider limiting the scope of attributes we can pass to just those of textarea and input elements:

type HTMLInputProps = React.InputHTMLAttributes<HTMLInputElement>;
type HTMLTextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;

{ customInputAttributes?: HTMLInputProps & HTMLTextAreaProps; }

Copy link
Author

Choose a reason for hiding this comment

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

Makes perfect sense! I should have updated the tests and the prop to allow for this. Thanks for reviewing!

@ggdouglas
Copy link
Contributor

Thanks for your interest in palantir/blueprint, @rallelind! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

I did sign this, but it does not seem like the PR updated. Do i need to do anything?

The PR is updated with the CLA check. You're all good!

…put, aswell as limiting the attributes to the TextArea and Input props
@rallelind rallelind requested a review from ggdouglas March 28, 2025 09:02
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.

Add support for custom HTML attributes on EditableText component's textarea
3 participants