question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot align text using align buttons in static Toolbar

See original GitHub issue
Uncaught TypeError: _this.props.setAlignment is not a function
    at BlockAlignmentButton._this.activate (bundle.js:19195)
    at Object.ReactErrorUtils.invokeGuardedCallback (bundle.js:19888)
    at executeDispatch (bundle.js:19672)
    at Object.executeDispatchesInOrder (bundle.js:19695)
    at executeDispatchesAndRelease (bundle.js:15722)
    at executeDispatchesAndReleaseTopLevel (bundle.js:15733)
    at Array.forEach (<anonymous>)
    at forEachAccumulated (bundle.js:28111)
    at Object.processEventQueue (bundle.js:15933)
    at runEventQueueInBatch (bundle.js:51468)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
avinessecommented, Apr 18, 2018

I also have this issue. Here is what the code is :

import createInlineToolbarPlugin from 'draft-js-inline-toolbar-plugin';
import { AlignBlockCenterButton } from 'draft-js-buttons';
import Editor from 'draft-js-plugins-editor';

class TextEditor extends Component {
  constructor(props) {
    super(props);
    let InlineToolbarStructure = [AlignBlockCenterButton];

    let InlineToolbarPlugin = createInlineToolbarPlugin({
      structure: InlineToolbarStructure,
    });
    let pluginsArray = [InlineToolbarPlugin];
    this.state = {
      plugins: pluginsArray,
    };
  }

  render() {
    let { plugins } = this.state;

    let InlineToolbar = plugins[0].InlineToolbar;
    let classes = [];
    let props = {};

    return (
      <div {...props}>
        <Editor
          [...some onChange, onBlur, etc.]
          plugins={plugins}
        />
        <InlineToolbar />
      </div>
    );
  }
}

react version is 16.0.0 react-dom is also 16.0.0

The error is the same as above, and appears when clicking on the ‘center’ icon present in the toolbar.

Uncaught TypeError: _this.props.setAlignment is not a function
    at BlockAlignmentButton._this.activate (createBlockAlignmentButton.js?c7ca:45)
    at HTMLUnknownElement.callCallback (react-dom.development.js?cada:104)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?cada:142)
    at Object.invokeGuardedCallback (react-dom.development.js?cada:191)
    at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js?cada:205)
    at executeDispatch (react-dom.development.js?cada:470)
    at executeDispatchesInOrder (react-dom.development.js?cada:492)
    at executeDispatchesAndRelease (react-dom.development.js?cada:590)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js?cada:601)
    at forEachAccumulated (react-dom.development.js?cada:571)
1reaction
juliankrispelcommented, Apr 17, 2018

Since we don’t have enough info to reproduce this bug we’ll need to close it. If you disagree please leave a comment and we’ll take it from there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ToolbarItem placement problem: Button text is not centered
The button text in the toolbar is obviously right aligned (The last "m" is closer to the edge than the beginning "c"). I...
Read more >
Inline CKEditor toolbar has no alignment buttons for h2 elements
It's impossible to enable align buttons on h2 editable. CKEditor cannot modify editable container, because that change simply wouldn't be ...
Read more >
[upstream] Alignment/justify buttons not appearing for ... - Drupal
It's a bug, the toolbar do not sync with input configs. we have an issue with patch for that but I can't find...
Read more >
text-align: right doesn't work... - DEV Community ‍ ‍
I found out this does not work because Button is enclosed by the parent element, 'Toolbar'. When you use 'text-align', it needs to...
Read more >
Align or arrange objects - Microsoft Support
To align a shape, text box, or WordArt, under Drawing Tools, click the Format tab. In the Arrange group, click Align, and then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found