Skip to content

[FluentNotification] Add Expand button behavior#2260

Open
nodes11 wants to merge 5 commits intomicrosoft:mainfrom
nodes11:dismiss_button_override
Open

[FluentNotification] Add Expand button behavior#2260
nodes11 wants to merge 5 commits intomicrosoft:mainfrom
nodes11:dismiss_button_override

Conversation

@nodes11
Copy link
Copy Markdown
Contributor

@nodes11 nodes11 commented Mar 31, 2026

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

This change introduces two new features for the FluentNotification, both of which revolve around an "Expand" button.

In the first use case, the expand button allows a text label to be fully visible if it is truncated. This is achieved through the addition of a new SwiftUI view called ExpandableText. Consumers can enable this feature by setting enableExpandableMessageText to true on the FluentNotification or the corresponding state object (depending on the initialization method).

The second use case exposes the expand button and a custom action block that a client can provide. This can be enabled by setting showExpandButtonInPlaceOfDismissButton to true and providing a non-nil expandButtonAction.

The current flaw with this change is that there are 2 separate feature toggles that control the same button. The user could encounter undefined behavior if both were enabled at the same time. I am considering other ways to expose the custom expand action behavior such as through a swipe gesture or tapping the notification view body.

Binary change

(how is our binary size impacted -- see https://github.com/microsoft/fluentui-apple/wiki/Size-Comparison)

Verification

Validated in the fluent demo controller, as well as in internal use cases.

Visual Verification

ExpandableText Demo:

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-03-31.at.16.11.53.mov

Expand Button Custom Action:

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-03-31.at.16.12.12.mov

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@nodes11 nodes11 requested a review from a team as a code owner March 31, 2026 23:15
message: hasMessage ? message : nil,
attributedMessage: hasAttribute && hasMessage ? attributedMessage : nil,
messageLineLimit: messageLineLimit,
enableExandableMessageText: expandButtonMode == 1,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: enableExpandableMessageText

/// Action to be dispatched by the dismiss button on the trailing edge of the control.
var defaultDismissButtonAction: (() -> Void)? { get set }

/// If dismiss button should be replaced an expand button
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: by an

/// - isFlexibleWidthToast: Whether the width of the toast is set based on the width of the screen or on its contents.
/// - message: Optional text for the main title area of the control. If there is a title, the message becomes subtext.
/// - attributedMessage: Optional attributed text for the main title area of the control. If there is a title, the message becomes subtext. If set, it will override the message parameter.
/// - messageLineLimit: The maximum number of lines the message can show. Any exess text is truncated.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: excess

/// - message: Optional text for the main title area of the control. If there is a title, the message becomes subtext.
/// - attributedMessage: Optional attributed text for the main title area of the control. If there is a title, the message becomes subtext. If set, it will override the message parameter.
/// - messageLineLimit: The maximum number of lines the message can show. Any exess text is truncated.
/// - enableExandableMessageText: If enabled, a expand button will be shown in place of the dimiss icon when the text is truncted. Tapping the expand button will display all lines of text.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: truncated

titleLabel
}
messageLabel.lineLimit(state.messageLineLimit > 0 ? state.messageLineLimit : nil)
if hasSecondTextRow {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I can't see the whitespace difference here but could we double check

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.

2 participants