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

Bug Fix: allow click of label and box for box-radio component #10586

Merged
merged 3 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ui/app/styles/components/box-radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
opacity: 0.5;
}

input[type='radio'].radio {
position: absolute;
z-index: 1;
opacity: 0;
}

input[type='radio'].radio + label {
border: 1px solid $grey-light;
border-radius: 50%;
Expand Down
14 changes: 8 additions & 6 deletions ui/lib/core/addon/components/box-radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
* @param {string} [tooltipMessage=default] - The message that shows in the tooltip if the radio option is disabled
*/

import Component from '@ember/component';
import Component from '@glimmer/component';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

import layout from '../templates/components/box-radio';
import { setComponentTemplate } from '@ember/component';

export default Component.extend({
layout,
disabled: false,
tooltipMessage: 'This option is not available to you at this time.',
});
class BoxRadio extends Component {
disabled = false;
tooltipMessage = 'This option is not available to you at this time.';
}

export default setComponentTemplate(layout, BoxRadio);
48 changes: 23 additions & 25 deletions ui/lib/core/addon/templates/components/box-radio.hbs
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
{{#if disabled}}
{{#if @disabled}}
<div class="box-radio-spacing">
<ToolTip
@verticalPosition="above"
@horizontalPosition="center"
as |T|>
<T.trigger @tabindex="-1">
<label
for={{type}}
for={{@type}}
class="box-radio is-disabled is-marginless"
data-test-mount-type-radio
data-test-mount-type={{type}}
data-test-mount-type={{@type}}
>
<Icon
@glyph={{glyph}}
@glyph={{@glyph}}
@size="xl"
class="has-text-grey-light"
/>
{{displayName}}
{{@displayName}}
<RadioButton
@value={{type}}
@value={{@type}}
@radioClass="radio"
@groupValue={{groupValue}}
@changed={{onRadioChange}}
@name={{groupName}}
@radioId={{type}}
@disabled={{disabled}}
@groupValue={{@groupValue}}
@changed={{@onRadioChange}}
@name={{@groupName}}
@radioId={{@type}}
@disabled={{@disabled}}
/>
<label for={{type}}></label>
</label>
</T.trigger>
<T.content @class="tool-tip">
<div class="box">
{{tooltipMessage}}
{{@tooltipMessage}}
</div>
</T.content>
</ToolTip>
</div>
{{else}}
<div class="box-radio-spacing">
<label
for={{type}}
for={{@type}}
class="box-radio is-marginless
{{if (eq groupValue type) " is-selected"}}"
{{if (eq @groupValue @type) " is-selected"}}"
data-test-mount-type-radio
data-test-mount-type={{type}}
data-test-mount-type={{@type}}
>
<Icon
@glyph={{glyph}}
@glyph={{@glyph}}
@size="xl"
class="has-text-grey-light"
/>
{{displayName}}
{{@displayName}}
<RadioButton
@value={{type}}
@value={{@type}}
@radioClass="radio"
@groupValue={{mountType}}
@changed={{onRadioChange}}
@name={{groupName}}
@radioId={{type}}
@disabled={{disabled}}
@groupValue={{@mountType}}
@changed={{@onRadioChange}}
@name={{@groupName}}
@radioId={{@type}}
@disabled={{@disabled}}
/>
<label for={{type.type}}></label>
</label>
</div>
{{/if}}