Skip to content

Commit

Permalink
fix: pass segment value in change event
Browse files Browse the repository at this point in the history
  • Loading branch information
felixw committed Jan 25, 2024
1 parent ff396e6 commit 96f0982
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/components/src/components/segment/segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,17 @@ export class Segment {
@Event({ eventName: 'scale-click' }) scaleClick!: EventEmitter<{
id: string;
selected: boolean;
value: string;
}>;
/** @deprecated in v3 in favor of kebab-case event names */
@Event({ eventName: 'scaleClick' }) scaleClickLegacy!: EventEmitter<{
id: string;
selected: boolean;
value: string;
}>;

private focusableElement: HTMLElement;
private value: string;

@Method()
async setFocus() {
Expand All @@ -101,8 +104,9 @@ export class Segment {
const hasText = nodeNames.includes('#text');
const hasIcon = nodeNames.includes('SCALE-ICON')
this.iconOnly = hasIcon && !hasText;
this.iconText = hasIcon && hasText;
this.iconText = hasIcon && hasText;
this.handleSelectedIcon();
this.value = this.hostElement.textContent.trim();
}

componentDidLoad() {
Expand Down Expand Up @@ -169,6 +173,7 @@ export class Segment {
emitEvent(this, 'scaleClick', {
id: this.segmentId,
selected: this.selected,
value: this.value,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { emitEvent } from '../../utils/utils';
interface SegmentStatus {
id: string;
selected: boolean;
value?: string;
}

@Component({
Expand Down Expand Up @@ -136,7 +137,6 @@ export class SegmentedButton {
this.propagatePropsToChildren();
this.position = 0;
this.status = tempState;

}

componentWillUpdate() {
Expand Down

0 comments on commit 96f0982

Please sign in to comment.