Skip to content

Adding callback mechanism for Stackable Snackbar#820

Open
pranjal-glowingstar wants to merge 7 commits intomicrosoft:masterfrom
pranjal-glowingstar:pranjal/snackbarIconFix
Open

Adding callback mechanism for Stackable Snackbar#820
pranjal-glowingstar wants to merge 7 commits intomicrosoft:masterfrom
pranjal-glowingstar:pranjal/snackbarIconFix

Conversation

@pranjal-glowingstar
Copy link

@pranjal-glowingstar pranjal-glowingstar commented Feb 26, 2026

Problem :-

As of now we dont have a way to know if the text is not truncated inside the message container. We will need a callback at the icon level probably with truncation param to decide the correct icon for such cases.

Root cause :-

There is no callback at icon level to determine which Icon to show when text is truncated or not.

Fix :-

Added a callback that will give a boolean to the usecase to tell if the text is truncated or not and would expect a FluentIcon from the usecase and render it accordingly.

Validations :-

Build successful and behaviour is working as expected.

(how the change was tested, including both manual and automated tests)

Screenshots

Before After
Screenshot or description before this change Screenshot or description with this change

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • Automated Tests
  • Documentation and demo app examples
  • VoiceOver and Keyboard Accessibility
  • Internationalization and RTL layouts
  • Size classes and window sizes (notched devices, multitasking, different window sizes, etc)

@pranjal-glowingstar
Copy link
Author

@microsoft-github-policy-service agree company="Microsoft"

@pranjal-glowingstar pranjal-glowingstar marked this pull request as ready for review March 5, 2026 05:05
@pranjal-glowingstar pranjal-glowingstar requested a review from a team as a code owner March 5, 2026 05:05
Copilot AI review requested due to automatic review settings March 5, 2026 05:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a callback-based mechanism in the stackable Snackbar component to allow the trailing icon to be selected dynamically based on whether the message text is visually truncated.

Changes:

  • Added a getTrailingIconBasedOnOverflow callback to SnackBarItemModel and wired it via Text(onTextLayout=...) overflow detection.
  • Updated trailing icon rendering to use a locally computed trailingIcon state rather than always using model.trailingIcon.
  • Updated the demo activity to pass the new callback when constructing SnackBarItemModel.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
fluentui_notification/src/main/java/com/microsoft/fluentui/tokenized/notification/StackableSnackbar.kt Adds overflow-based trailing icon callback and updates trailing-icon rendering logic.
FluentUI.Demo/src/main/java/com/microsoft/fluentuidemo/V2StackableSnackbarActivity.kt Updates demo usage to provide the new callback parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Pranjal Singh added 4 commits March 5, 2026 10:57
# Conflicts:
#	fluentui_notification/src/main/java/com/microsoft/fluentui/tokenized/notification/StackableSnackbar.kt
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