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

fix(radio-button): polish click handling, hover, etc #2131

Merged
merged 1 commit into from
Sep 19, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ scale-radio-button {
display: flex;
flex-wrap: wrap;
align-items: center;
cursor: pointer;
width: fit-content;
}

Expand Down Expand Up @@ -128,15 +127,15 @@ scale-icon-alert-error {
cursor: pointer;
}

.radio-button:hover input:not(:checked):not([disabled]) {
.radio-button input:not(:checked):not([disabled]):hover {
box-shadow: none;
border-color: var(--telekom-color-ui-border-hovered);
background-color: var(--telekom-color-ui-state-fill-hovered);
}
.radio-button:hover input:not(:checked):not([disabled]) ~ label {
.radio-button input:not(:checked):not([disabled]):hover ~ label {
color: var(--color-primary-hover);
}
.radio-button:active input:not(:checked):not([disabled]) {
.radio-button input:not(:checked):not([disabled]):active {
border-color: var(--telekom-color-ui-border-pressed);
background-color: var(--telekom-color-ui-state-fill-pressed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,6 @@ export class RadioButton {
}
};

// Prevent click event being fired twice when the target is the label.
handleClick = (event: any) => {
event.stopPropagation();
if (!this.disabled) {
this.checked = true;
this.uncheckSiblings();
}
};

// We manually set `checked` to false on sibling <scale-radio-button> elements,
// otherwise they stayed `checked` after being clicked once, forever.
uncheckSiblings() {
Expand Down Expand Up @@ -137,7 +128,7 @@ export class RadioButton {

return (
<Host>
<div class={this.getCssClassMap()} onClick={this.handleClick}>
<div class={this.getCssClassMap()}>
<input
type="radio"
name={this.name}
Expand All @@ -149,9 +140,7 @@ export class RadioButton {
{...ariaInvalidAttr}
{...(this.helperText ? ariaDescribedByAttr : {})}
/>
<label htmlFor={this.inputId} onClick={this.handleClick}>
{this.label}
</label>
<label htmlFor={this.inputId}>{this.label}</label>
{!!this.helperText && (
<div
class="radio-button__meta"
Expand Down
Loading