Skip to content

Conversation

@adids1221
Copy link
Contributor

@adids1221 adids1221 commented Dec 14, 2025

Description

Adds support for rendering FloatingButton component with only the secondary button. When secondaryButton is provided without button prop, the component renders the secondary button with horizontal layout styling and outline stroke.

Breaking Changes:

  • FloatingButton now requires button prop to render primary button (previously rendered empty wrapper with only visible: true)

Logic Changes:

  • Secondary-only mode automatically uses horizontal layout
  • FullWidth support works correctly in horizontal layout with only primary button

Changelog

FloatingButton - Added support for rendering secondary button standalone.
Breaking: button prop is now required to render primary button.

Additional info

Support channel slack thread

@M-i-k-e-l
Copy link
Collaborator

@adids1221 please merge master after the monorepo change 🙏

@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Dec 18, 2025
expect(await buttonDriver.exists()).not.toBeTruthy();

renderTree.rerender(<TestCase visible/>);
renderTree.rerender(<TestCase visible button={button}/>);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you need to add this to the test? It's a problem if the default behavior has changed.

Copy link
Contributor Author

@adids1221 adids1221 Dec 21, 2025

Choose a reason for hiding this comment

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

I made a breaking change here, and I believe it's necessary.
Let me explain:

Previous behavior: When rendering FloatingButton with only visible: true (without button or secondaryButton props), it rendered an empty button wrapper with no title/label, which was redundant and not useful.

New behavior: Users must now explicitly provide either button or secondaryButton props to render buttons. If neither is provided, the component returns null (no rendering).

Why this change:

  • Removes redundant rendering of empty button wrappers
  • Makes the API explicit: provide a button prop to render a button
  • Improves clarity and prevents confusion from empty buttons

This breaking change is documented in the PR description under "Breaking Changes".
We can discuss if you'd like to adjust the approach.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@adids1221
Let's talk about this - not sure it qualifies as a breaking change, but if it does we cannot merge it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove the breaking change part from the Changelog (it's also generally best to have the Changelog in a single line unless it's actually two features) and add a ⚠️ to the start of the line

marginBottom: Spacings.s7,
marginLeft: 20
},
fullWidthSecondary: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

@adids1221 adids1221 Dec 21, 2025

Choose a reason for hiding this comment

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

now you can see the usage in renderSecondaryButton

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I do, see this

@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Dec 18, 2025
- Add support for rendering FloatingButton with only secondary button
- Secondary-only mode automatically uses horizontal layout with outline styling
- Add isSecondaryOnly and shouldSecondaryButtonFlex getters
- Fix fullWidth margin consistency for secondary-only button
- Refactor rendering logic to use positive checks for better readability
- Fix fullWidth support in horizontal layout with only primary button

Breaking: FloatingButton now requires button prop to render primary button (previously rendered empty wrapper with only visible: true)
@adids1221 adids1221 requested a review from M-i-k-e-l December 21, 2025 13:52
@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Dec 21, 2025
@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Dec 22, 2025
const buttonStyle = shouldUseHorizontalStyle
? [
styles.shadow,
fullWidth && this.isSecondaryOnly ? styles.fullWidthSecondaryMargin : styles.secondaryMargin,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't secondaryMargin and fullWidthSecondaryMargin the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, fixed.

marginBottom: Spacings.s7,
marginLeft: 20
},
fullWidthSecondary: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I do, see this

return secondaryButton && !this.isHorizontalLayout;
}

get shouldSecondaryButtonFlex() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This appears only once and the name is not too good, maybe we can remove the function and create a const below?
Not sure if there are other functions we can do that with.

return (
<View
row={this.isHorizontalLayout}
center={!!shouldCenter}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure you need the !!

const {withoutAnimation, visible, fullWidth, testID} = this.props;
// NOTE: keep this.firstLoad as true as long as the visibility changed to true
const {withoutAnimation, visible, fullWidth, testID, button, secondaryButton} = this.props;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you remove the two comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure, revert this change

Comment on lines 143 to 145
const bottom = this.isSecondaryVertical ? Spacings.s4 : bottomMargin || Spacings.s8;
const left = this.isSecondaryHorizontal || fullWidth ? Spacings.s4 : undefined;
const right = this.isSecondaryHorizontal ? 20 : fullWidth ? Spacings.s4 : undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is not your code, WDYT about making it marginBottom etc?

const left = this.isSecondaryHorizontal || fullWidth ? Spacings.s4 : undefined;
const right = this.isSecondaryHorizontal ? 20 : fullWidth ? Spacings.s4 : undefined;
const shadowStyle = button && !button.outline && !button.link ? styles.shadow : undefined;
const marginStyle = {marginTop: 16, marginBottom: bottom, marginLeft: left, marginRight: right};
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can also change 20 and 16 to Spacings.s5 and Spacings.s4, not a must


if (secondaryButton) {
const bgColor = secondaryButton.backgroundColor || Colors.$backgroundDefault;
const shouldUseHorizontalStyle = this.isHorizontalLayout;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use this.isHorizontalLayout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are multiple usage here of shouldUseHorizontalStyle I think it's better for readability

@adids1221 adids1221 requested a review from M-i-k-e-l December 24, 2025 15:12
@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants