wfp / designsystem

World Food Programme User Interface Kit. Developer kit for implementing WFP web style guideline.
http://www.wfp.org/UIGuide
Apache License 2.0
224 stars 103 forks source link

Pagination component unwanted behavior on next/previous page button click #514

Closed t04st3r closed 2 years ago

t04st3r commented 2 years ago

Detailed description

Describe in detail the issue you're having.

Using the Pagination component, if you place it inside a form on next/previous button click it will submit the form

Is this a feature request (new component, new icon), a bug, or a general issue?

this is a bug

Is this issue related to a specific component?

yes, the Pagination component

What did you expect to happen? What happened instead? What would you like to see changed?

upon next/previous page click it should not submit any form, but change the page

What browser are you working in?

Chrome Version 98.0.4758.80 (Official Build) (64-bit) Firefox Version 96.0.3 (64-bit)

What version of the WFP UI (Carbon Design System) are you using?

1.17.1

What offering/product do you work on? Any pressing ship or release dates we should be aware of?

enhancing the Goods Transport Form for the Service Market Place web app, it would be so nice to have fixed before April the 8th 2022 that we will showcase the new features including goods item pagination during the sprint demo.

Additional information

The fix is just to add a type attribute to the next and previous <button> something like <button type="button"></button> if you don't specify the type, the default type that is picked is submit and it will cause the unwanted form submission. I can open a PR with a quick fix for this. So far I just created a custom Pagination component locally starting from your codebase with the aforementioned fix and it works like a charm :rocket: