Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Toggle button labels do not toggle the button #566

Closed
jrenee42 opened this issue Jan 29, 2021 · 0 comments · Fixed by #568 or #584
Closed

Toggle button labels do not toggle the button #566

jrenee42 opened this issue Jan 29, 2021 · 0 comments · Fixed by #568 or #584
Assignees

Comments

@jrenee42
Copy link
Contributor

jrenee42 commented Jan 29, 2021

when you have toggle buttons like:

Screen Shot 2021-01-29 at 4 17 26 PM

you expect that clicking on the "Vertical" label will activate the vertical toggle/radio button and turn off the Horizontal button.
that doesn't work.

it is because of custom onClick handlers in the toggle implementation that this doesn't work; so switching the onClick handler to encompass the entire component to fix this.

worked on this with @mavarius
example code for the screenshot above; note that VERTICAL and HORIZONTAL are string constants

<FlexBox
  direction={FlexDirection.Column}
  margin={ComponentSize.Large}
  alignItems={AlignItems.FlexStart}
  style={{marginBottom: 12}}
 >
  <p>Legend Orientation</p>
     <Toggle
       tabIndex={1}
       value="horizontal"
       id="horizontal-legend-orientation"
       name="horizontal"
       checked={legendOrientation === HORIZONTAL}
       onChange={() => handleSetOrientation(HORIZONTAL)}
       type={InputToggleType.Radio}
       size={ComponentSize.ExtraSmall}
       color={ComponentColor['Primary']}
       appearance={Appearance['Outline']}
     >

    <InputLabel
      active={legendOrientation === 'horizontal'}
      htmlFor="horizontal-legend-orientation"
    >
      Horizontal
    </InputLabel>
  </Toggle>
  <Toggle
    tabIndex={2}
    value="vertical"
    id="vertical-legend-orientation"
    name="vertical"
    checked={legendOrientation === VERTICAL}
    onChange={() => handleSetOrientation(VERTICAL)}
    type={InputToggleType.Radio}
    size={ComponentSize.ExtraSmall}
    color={ComponentColor['Primary']}
    appearance={Appearance['Outline']}
  >
    <InputLabel
      active={legendOrientation === 'vertical'}
      htmlFor="vertical-legend-orientation"
    >
      Vertical
    </InputLabel>
  </Toggle>
</FlexBox>`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
1 participant