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

[Bugfix] Fix Dropdown bug and Update styling for feature balance measures #1583

Merged
merged 4 commits into from
Jul 28, 2022
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
12 changes: 12 additions & 0 deletions libs/dataset-explorer/src/lib/DataBalanceTab.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
import { descriptionMaxWidth } from "@responsible-ai/core-ui";

export interface IDataBalanceTabStyles {
boldText: IStyle;
callout: IStyle;
dropdownLongWidth: IStyle;
dropdownMedWidth: IStyle;
infoWithText: IStyle;
page: IStyle;
}
Expand All @@ -19,9 +22,18 @@ export const dataBalanceTabStyles: () => IProcessedStyleSet<IDataBalanceTabStyle
() => {
const theme = getTheme();
return mergeStyleSets<IDataBalanceTabStyles>({
boldText: {
fontWeight: 600
},
callout: {
margin: "-18px 0 0 0"
},
dropdownLongWidth: {
dropdown: { width: 200 }
},
dropdownMedWidth: {
dropdown: { width: 150 }
},
infoWithText: {
maxWidth: descriptionMaxWidth,
width: "100%"
Expand Down
25 changes: 15 additions & 10 deletions libs/dataset-explorer/src/lib/FeatureBalanceMeasuresChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { localization } from "@responsible-ai/localization";
import _ from "lodash";
import React from "react";

import { dataBalanceTabStyles } from "./DataBalanceTab.styles";
import { FeatureBalanceMeasuresDescription } from "./FeatureBalanceMeasuresDescription";
import {
FeatureBalanceMeasuresMap,
Expand Down Expand Up @@ -71,6 +72,8 @@ export class FeatureBalanceMeasuresChart extends React.PureComponent<
);
}

const styles = dataBalanceTabStyles();

const labelOptions = _.uniq(Object.keys(featureBalanceMeasures)).map(
(label, index) => ({ key: index, text: label } as IDropdownOption)
);
Expand Down Expand Up @@ -109,7 +112,7 @@ export class FeatureBalanceMeasuresChart extends React.PureComponent<
</Stack.Item>
<Stack.Item>
<Dropdown
styles={{ dropdown: { width: 150 } }}
className={styles.dropdownMedWidth}
id="labelDropdown"
options={labelOptions}
selectedKey={this.state.selectedLabelIndex}
Expand All @@ -127,7 +130,7 @@ export class FeatureBalanceMeasuresChart extends React.PureComponent<
</Stack.Item>
<Stack.Item>
<Dropdown
styles={{ dropdown: { width: 150 } }}
className={styles.dropdownMedWidth}
id="featureDropdown"
options={featureOptions}
selectedKey={this.state.selectedFeatureIndex}
Expand All @@ -145,7 +148,7 @@ export class FeatureBalanceMeasuresChart extends React.PureComponent<
</Stack.Item>
<Stack.Item>
<Dropdown
styles={{ dropdown: { width: 200 } }}
className={styles.dropdownLongWidth}
id="measureDropdown"
options={measureOptions}
selectedKey={this.state.selectedMeasureIndex}
Expand Down Expand Up @@ -176,7 +179,9 @@ export class FeatureBalanceMeasuresChart extends React.PureComponent<

{/* Renders the description of the chosen measure */}
<Stack.Item>
<Text style={{ fontWeight: 600 }}>{selectedMeasure} </Text>
{/* The description is a paragraph with the format "<bolded measure name> <measure desc>". Because the
measure desc is long and usually wraps to a new line, a Stack containing Label and Text cannot be used. */}
<Text className={styles.boldText}>{selectedMeasure} </Text>
<Text>
{FeatureBalanceMeasuresMap.get(selectedMeasure)?.Description}
</Text>
Expand All @@ -201,26 +206,26 @@ export class FeatureBalanceMeasuresChart extends React.PureComponent<
_: React.FormEvent<HTMLDivElement>,
item?: IDropdownOption
): void => {
if (item?.key) {
this.setState({ selectedLabelIndex: item.key as number });
if (typeof item?.key === "number") {
this.setState({ selectedLabelIndex: item.key });
}
};

private setSelectedFeature = (
_: React.FormEvent<HTMLDivElement>,
item?: IDropdownOption
): void => {
if (item?.key) {
this.setState({ selectedFeatureIndex: item.key as number });
if (typeof item?.key === "number") {
this.setState({ selectedFeatureIndex: item.key });
}
};

private setSelectedMeasure = (
_: React.FormEvent<HTMLDivElement>,
item?: IDropdownOption
): void => {
if (item?.key) {
this.setState({ selectedMeasureIndex: item.key as number });
if (typeof item?.key === "number") {
this.setState({ selectedMeasureIndex: item.key });
}
};
}