Bug: Buttons submit form

5 posts, 1 answers
  1. Thomas
    Thomas avatar
    5 posts
    Member since:
    Jul 2016

    Posted 25 Aug Link to this post

    Hi,

     

    I am using the latest Kendo UI version (2016.2.714) and found a bug in the colorpicker.

    The buttons (Apply and Cancel) are rendered as

    <button class="k-button k-primary apply">Apply</button>
    <button class="k-button cancel">Cancel</button>

    (see kendo.colorpicker.js line 504 for details or check  the source on github)

    When included in a form both of the buttons always cause the form to get submitted when they get clicked as this is the common behavior of a button tag. Both of them should have the type attribute set to "button" to prevent the form from getting submitted. The rendered buttons should look like this:

     

    <button type="button" class="k-button k-primary apply">Apply</button>
    <button  type="button" class="k-button cancel">Cancel</button>

     

    Best regards

     

    Thomas

  2. Answer
    Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 29 Aug Link to this post

    Hello Thomas,

    You are right that the ColorPicker's buttons have no type="button" attribute, but the popup that includes these buttons is rendered outside the form. Therefore, clicking the buttons does not submit it.

    Here you are a dojo that demonstrates the described scenario: http://dojo.telerik.com/AsadIR

    Regards,
    Ianko
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
  4. Thomas
    Thomas avatar
    5 posts
    Member since:
    Jul 2016

    Posted 29 Aug in reply to Ianko Link to this post

    Hi Ianko,

    thanks for your reply. I see, you are right, the Color Picker is rendered outside the form. But as I started this thread the buttons in the Color Picker did indeed submit my form in my application and for some reason they do not now and I can't figure out what I have changed to make behave them correctly. It looks like there was in bug in my code that caused this false behavior, so sorry for the confusion.

    However, is there any disadvantage in adding the type="button" attribute?

     

    Best regards

     

    Thomas

  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 29 Aug Link to this post

    Hello Thomas,

    As this is a dynamically rendered element HTML compliant requirements regarding attributes are not a must. Basically, the only advantage for not having this attribute that I can think of is prevention of unneeded code. However, having them also does not break any of the HTML rendered and I am not aware of any disadvantages for that. 

    If you need these attributes set up, you can always use few lines of JavaScript code to put them in the button tags. Also, if you find any particular advantages from doing that you can always submit this as a feature request on UserVoice, so that the dev team can consider it for possible future improvement.

    Regards,
    Ianko
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  6. Thomas
    Thomas avatar
    5 posts
    Member since:
    Jul 2016

    Posted 29 Aug in reply to Ianko Link to this post

    Hi Ianko

     

    thanks again for your help, the problem is gone now as it seemed to be a bug in my code that caused the ColorPicker buttons to submit the form.

    However, the UserVoice is a great idea.

     

    Best regards

     

    Thomas

Back to Top
Kendo UI is VS 2017 Ready