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

PF4 Dropdown: No button type submits page when selected #1194

Closed
dlabrecq opened this issue Jan 16, 2019 · 4 comments
Closed

PF4 Dropdown: No button type submits page when selected #1194

dlabrecq opened this issue Jan 16, 2019 · 4 comments
Assignees
Milestone

Comments

@dlabrecq
Copy link
Member

dlabrecq commented Jan 16, 2019

Looking at the generated code by the PF4 Dropdown, it creates a button without any specified type, which (by default) attempts to submit the page/form. This causes the page to refresh and we end up with a blank page due to a submit error.

PF4 Dropdown output:

screen shot 2019-01-16 at 10 30 53 am

The workaround I'm forced to implement prevents the onClick event from propagating any higher.

Dropdown usage:

<Dropdown
  onClick={event => event.preventDefault()} <<< WORKAROUND
  onSelect={this.handleGroupBySelect}
  toggle={
    <DropdownToggle onToggle={this.handleGroupByToggle}>
      {t(`group_by.values.${groupById}`)}
   </DropdownToggle>
  }
  isOpen={isGroupByOpen}
  dropdownItems={groupByOptions.map(option => (
    <DropdownItem
      key={option.value}
      onClick={event =>
        this.handleGroupByItemClick(event, option.value)
      }
    >
      {t(`group_by.values.${option.label}`)}
    </DropdownItem>
  ))}
/>
@kmcfaul kmcfaul self-assigned this Jan 16, 2019
@tlabaj tlabaj added p1 labels Jan 16, 2019
@kmcfaul
Copy link
Contributor

kmcfaul commented Jan 17, 2019

#1148 should have set a type property on the toggle button, defaulting to 'button' when nothing is passed in. Are you still experiencing the issue?

@dlabrecq
Copy link
Member Author

dlabrecq commented Jan 18, 2019

I installed the latest react-core v1.48.0, and see the type="button", but the page is still being submitted.

@kmcfaul
Copy link
Contributor

kmcfaul commented Jan 21, 2019

Can you try defining component='button' in your DropdownItem mapping? I'm looking at the code and by default it wraps items in an anchor tag, which is possibly the reason for the submission.

@rachael-phillips rachael-phillips added this to the 1.0.0-alpha.7 milestone Jan 21, 2019
@dlabrecq
Copy link
Member Author

I don't see an anchor tag in the output, but adding component='button' seems to resolve the issue.

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

4 participants