Skip to content

Commit ba95d30

Browse files
authored
[MOO-1296]: Fix Icon Alignment in Floating Action Buttons (#123)
2 parents 3a245fe + 56d2e08 commit ba95d30

14 files changed

+146
-22
lines changed

packages/pluggableWidgets/floating-action-button-native/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We have fixed an issue where icons within Floating Action Buttons were not properly centered.
12+
913
## [4.0.1] - 2023-10-24
1014

1115
### Fixed
1216

13-
- We have fixed an error related to useNativeDriver.
17+
- We have fixed an error related to useNativeDriver.
1418

1519
## [4.0.0] - 2023-3-28
1620

packages/pluggableWidgets/floating-action-button-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "floating-action-button-native",
33
"widgetName": "FloatingActionButton",
4-
"version": "4.0.1",
4+
"version": "4.0.2",
55
"license": "Apache-2.0",
66
"repository": {
77
"type": "git",

packages/pluggableWidgets/floating-action-button-native/src/FloatingActionButton.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ export class FloatingActionButton extends Component<FloatingActionButtonProps<Fl
6262
const isActive = this.state.active && this.props.secondaryButtons.length > 0;
6363
const source = isActive ? activeIconSource : iconSource;
6464
const style = isActive ? { transform: [{ rotate: "-180deg" }] } : {};
65+
const buttonContainerStyle = [this.styles.button, this.styles.buttonContainer];
6566

6667
return (
67-
<View testID={"FloatingAction$IconView"} style={[style, this.styles.buttonIconContainer]}>
68-
<Icon icon={source} size={this.styles.buttonIcon.size} color={this.styles.buttonIcon.color} />
68+
<View testID={"FloatingAction$IconView"} style={buttonContainerStyle}>
69+
<View style={[style, this.styles.buttonIconContainer]}>
70+
<Icon icon={source} size={this.styles.buttonIcon.size} color={this.styles.buttonIcon.color} />
71+
</View>
6972
</View>
7073
);
7174
}

packages/pluggableWidgets/floating-action-button-native/src/__tests__/FloatingActionButton.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FloatingActionButton } from "../FloatingActionButton";
66
import { actionValue, dynamicValue } from "@mendix/piw-utils-internal";
77
import { NativeIcon } from "mendix";
88
import { Icon } from "mendix/components/native/Icon";
9+
import { ReactTestInstance } from "react-test-renderer";
910

1011
describe("FloatingActionButton", () => {
1112
let defaultProps: FloatingActionButtonProps<FloatingActionButtonStyle>;
@@ -116,7 +117,7 @@ describe("FloatingActionButton", () => {
116117
);
117118
const transformStyle = [{ transform: [{ rotate: "-180deg" }] }];
118119

119-
const iconView = getByTestId("FloatingAction$IconView");
120+
const iconView = getByTestId("FloatingAction$IconView").children[0] as ReactTestInstance;
120121
const iconComponent = iconView.findByType(Icon);
121122
expect(iconComponent.props.icon).toEqual(icon.value);
122123
expect(iconView.props.style).not.toEqual(expect.arrayContaining(transformStyle));

0 commit comments

Comments
 (0)