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

RichText component: pasting text ignores disableLineBreaks setting #67387

Open
3 of 6 tasks
markhowellsmead opened this issue Nov 28, 2024 · 4 comments · May be fixed by #67412
Open
3 of 6 tasks

RichText component: pasting text ignores disableLineBreaks setting #67387

markhowellsmead opened this issue Nov 28, 2024 · 4 comments · May be fixed by #67412
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@markhowellsmead
Copy link

markhowellsmead commented Nov 28, 2024

Description

When pasting text into a RichText component with disableLineBreaks={true}, the line breaks (\r and \n) are replaced with br tags instead of being stripped. Possibly related: #59548.

Step-by-step reproduction instructions

See code below. Copy and paste a text into the field which contains plain text line breaks (not br tags).

Screenshots, screen recording, code snippet

const {attributes, setAttributes} = props;
const {title} = attributes;

 <RichText
    tagName='h3'
    placeholder=__('Add a title…', 'sha')}
    value={title}
    allowedFormats={[]}
    disableLineBreaks={true}
    onChange={value => {
        setAttributes({ title: value });
    }}
    />

Environment info

  • WordPress 6.7.1

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@markhowellsmead markhowellsmead added the [Type] Bug An existing feature does not function as intended label Nov 28, 2024
@markhowellsmead
Copy link
Author

cc @t-hamano.

@Mamaduka Mamaduka added the [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable label Nov 28, 2024
@t-hamano
Copy link
Contributor

@markhowellsmead Thanks for the report. I was able to reproduce this issue too.

My test steps are as follows:

cd2f4c0c4fda768d3d89750b6be15d57.mp4

My feeling is that this isn't intended. Perhaps the disableLineBreaks prop needs to check for the paste event as well as the Enter key.

cc @ellatrix

@markhowellsmead
Copy link
Author

Thanks Aki!

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 29, 2024
@Infinite-Null
Copy link
Contributor

Infinite-Null commented Nov 29, 2024

Hi @t-hamano, @markhowellsmead,

I’ve submitted a PR #67412 with a potential solution and would greatly appreciate it if you could take a moment to test and review it. Your feedback would be valuable.

Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants