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

Problem in radio controls of heading-with-icon custom block component #67

Open
marcosmanto opened this issue Jul 23, 2021 · 0 comments
Open

Comments

@marcosmanto
Copy link

marcosmanto commented Jul 23, 2021

Hi Inran,
I am following your excellent tutorial on YT and the code present in:
aquila-master\assets\src\js\gutenberg\blocks\heading-with-icon\edit.js

didn't work for me. When I clicked in radio buttons the option didn't change.
I apply this change in edit.js and it worked for me:

  <RadioControl
      label={ __( 'Select the icon', 'aquila' ) }
      help={ __( 'Controls icon selection', 'aquila' ) }
      selected={ option }
      options={ [
	      { label: 'Dos', value: 'dos' },
	      { label: "Dont's", value: 'donts' },
      ] }
      onChange={ ( optionVal ) => {
	      setAttributes( { option: optionVal } );
      } }
  />

Instead of using setAttributes( { optionVal } ) I changed to setAttributes( { option: optionVal } )

Same for change the content on typing (setAttributes( { content: contentVal } ):

<RichText
  tagName="h4" // The tag here is the element output and editable in the admin
  className={ className }
  value={ content } // Any existing content, either from the database or an attribute default
  onChange={ ( contentVal ) => setAttributes( { content: contentVal } ) } // Store updated content as a block attribute
  placeholder={ __( 'Heading…', 'aquila' ) } // Display this text before any content has been added by the user
/>

Thanks for your great work

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

No branches or pull requests

1 participant