Title: Attribute form NumberControl doesn&#8217;t update
Last modified: February 14, 2021

---

# Attribute form NumberControl doesn’t update

 *  [katarzynapa](https://wordpress.org/support/users/katarzynapa/)
 * (@katarzynapa)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/attribute-form-numbercontrol-doesnt-update/)
 * I am creating my own block. And I’ve got a problem. My scenario:
 * 1. I update attribute through NumberControl (it doesn’t lose focus yet).
    2. 
   I click “Update” page button. And an attribute from NumberControl is not updated.
 * How can I fix it?
 * Kasia

Viewing 1 replies (of 1 total)

 *  Thread Starter [katarzynapa](https://wordpress.org/support/users/katarzynapa/)
 * (@katarzynapa)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/attribute-form-numbercontrol-doesnt-update/#post-14059018)
 * My video scenario: [⌊video scenario⌉](https://i0.wp.com/i.imgur.com/zG45Ct5.gif?ssl=1)
 * My code:
 *     ```
       const InspectorControls = blockEditor.InspectorControls;
   
       const PanelBody = components.PanelBody;
       const PanelRow = components.PanelRow;
   
       const NumberControl = components.__experimentalNumberControl;
   
       const setStyle = ( props ) => {
           let style = {};
   
           if (props.attributes.size != 20) {
               style.width = props.attributes.size;
               style.height = props.attributes.size;
           }
   
           return style;
       };
   
       blocks.registerBlockType( 'testblock/test', {
           apiVersion: 2,
           title: 'Test block',
           icon: 'format-image',
           category: 'design',
           example: {
               attributes: {
                   size: 20
               },
           },
           attributes: {
               size: {
                   type: 'number',
                   default: 20
               }
           },
           edit: ( props ) => {                            
   
               return (
   
                   <>
                       {
                       <InspectorControls>
                           <PanelBody title="Element Settings" initialOpen={ true }>
                               <PanelRow>
                                   <NumberControl
                                       isShiftStepEnabled={ true }
                                       onChange={ newSize => props.setAttributes( { size: newSize } ) }
                                       label={ 'Element size:' } 
                                       labelPosition={ 'side' }
                                       shiftStep={ 1 }
                                       value={ props.attributes.size }
                                   />
                               </PanelRow> 
                           </PanelBody>
                       </InspectorControls>
                       }
                       <div
                           style={ setStyle( props ) } 
                           className={ 'test-block' }
                       >
                       </div>
                   </>
               );
           },
           save: ( props ) => {
   
               return (
                   <div
                       style={ setStyle( props ) } 
                       className={ 'test-block' }
                   >
                   </div>
               );  
           },
       });
       ```
   
 *     ```
       .test-block {
         background: red;
         width: 20px;
         height: 20px;
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Attribute form NumberControl doesn’t update’ is closed to new replies.

 * ![](https://ps.w.org/gutenberg/assets/icon-256x256.jpg?rev=1776042)
 * [Gutenberg](https://wordpress.org/plugins/gutenberg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gutenberg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gutenberg/)
 * [Active Topics](https://wordpress.org/support/plugin/gutenberg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gutenberg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gutenberg/reviews/)

## Tags

 * [attributes](https://wordpress.org/support/topic-tag/attributes/)

 * 1 reply
 * 1 participant
 * Last reply from: [katarzynapa](https://wordpress.org/support/users/katarzynapa/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/attribute-form-numbercontrol-doesnt-update/#post-14059018)
 * Status: not resolved