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

Redo/Undo button icons are not customizable #195

Closed
rmakovyak opened this issue May 7, 2019 · 4 comments
Closed

Redo/Undo button icons are not customizable #195

rmakovyak opened this issue May 7, 2019 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@rmakovyak
Copy link

Do you want to request a feature or report a bug?
Bug
What is the current behaviour?
Redo and Undo controls buttons cannot be overwritten with custom icons
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. GIFs and screenshots are very helpful too.

Editor config that I'm using

<DraftailEditor
        {...otherProps}
        rawContentState={fromHTML(content)}
        onSave={data => onChange(toHTML(data))}
        showUndoControl={{
          description: t('editor.undo'),
          icon: <FontAwesomeIcon icon={faUndo} size="xs" />,
        }.UNDO}
        showRedoControl={{
          description: t('editor.redo'),
          icon: <FontAwesomeIcon icon={faRedo} size="xs" />,
        }}
        inlineStyles={[
          {
            type: INLINE_STYLE.UNDERLINE,
            icon: <FontAwesomeIcon icon={faUnderline} size="xs" />,
            description: t('editor.underline'),
          }
        ]}
      />

Result:

Screenshot 2019-05-07 at 11 27 18

The icon does not appear inside button control.
It works correctly for INLINE or BLOCK styles blocks though.
What is the expected behaviour?
The icon should appear inside button control.
Which versions of Draftail + Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draftail or Draft.js?

^1.0.0, Chrome, MacOS, don't know

@thibaudcolas
Copy link
Collaborator

Hey @rmakovyak, thanks for the report!

Looking at the code, it does seem like the icon isn't forwarded to those buttons:

{showUndoControl ? (
<ToolbarButton
name={UNDO_TYPE}
onClick={onUndoRedo}
label={getButtonLabel(UNDO_TYPE, showUndoControl)}
title={getButtonTitle(UNDO_TYPE, showUndoControl)}
/>
) : null}
{showRedoControl ? (
<ToolbarButton
name={REDO_TYPE}
onClick={onUndoRedo}
label={getButtonLabel(REDO_TYPE, showRedoControl)}
title={getButtonTitle(REDO_TYPE, showRedoControl)}
/>

This is how it's done for the line break, the implementation should be the same for undo/redo:

icon={
typeof enableLineBreak !== "boolean" ? enableLineBreak.icon : null
}

Would you be up for making a PR to fix this?

@thibaudcolas thibaudcolas added bug Something isn't working good first issue Good for newcomers labels May 7, 2019
@thibaudcolas thibaudcolas added this to the v1.3.0 milestone May 7, 2019
@rmakovyak
Copy link
Author

rmakovyak commented May 7, 2019

hey @thibaudcolas! thanks for quick response. Yes, i'll make a PR with a fix

@thibaudcolas
Copy link
Collaborator

Fixed in #196. Sorry it took me so long to get back to this – I’ll try to make a release shortly.

@thibaudcolas
Copy link
Collaborator

This is now released in Draftail v1.3.0 – https://www.draftail.org/blog/2019/08/15/draftail-v1-3-0-community-improvements-beyond-wagtail thanks again @rmakovyak for reporting & fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants