Skip to content

Fix NavigationBar indicator overlay color #164484

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

Merged

Conversation

bleroux
Copy link
Contributor

@bleroux bleroux commented Mar 3, 2025

Description

This PR fixes NavigationBar lacking visual feedback on the active destination indicator.

Before:

The navigation indicator does not change color when hovered or focused:

NavigationBarIndicatorOverlayBefore.mp4

After:

The navigation indicator color changes (slightly darker):

NavigationBarIndicatorOverlayAfter.mp4

Related Issue

Fixes NavigationBar lacks visual feedback when focused or hovered

Tests

  • Updates several helper functions which are used by several tests.
  • Updates several test: adding an Ink widget changes the coordinates used in several tests because these coordinates are now relative to the Ink offset.
  • Will impact fours golden tests which were capturing the bad behavior (indicator color not changing when hovered or focused).

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Mar 3, 2025
@bleroux bleroux force-pushed the fix_navigation_bar_indicator_overlay branch 3 times, most recently from d0de54c to 4a674ae Compare March 4, 2025 14:14
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #164484 at sha 4a674ae

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Mar 4, 2025
@bleroux bleroux force-pushed the fix_navigation_bar_indicator_overlay branch from 4a674ae to 3955195 Compare March 5, 2025 09:53
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #164484 at sha 3955195

Copy link
Member

@TahaTesser TahaTesser left a comment

Choose a reason for hiding this comment

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

LGTM! (To trigger Google testing)

@bleroux bleroux requested a review from justinmc March 10, 2025 07:47
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍 . The Google failures were all expected.

Comment on lines -856 to +857
child: Container(
child: Ink(
Copy link
Contributor

Choose a reason for hiding this comment

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

Simple fix 👍

@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 13, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 13, 2025
Merged via the queue into flutter:master with commit c6c5186 Mar 13, 2025
75 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 13, 2025
@bleroux bleroux deleted the fix_navigation_bar_indicator_overlay branch March 13, 2025 09:12
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
@bggRGjQaUbCoE
Copy link

bggRGjQaUbCoE commented May 21, 2025

There is a bug caused by this change, selected nav will not change if switch nav by code instead of clicking.

@bleroux
Copy link
Contributor Author

bleroux commented May 21, 2025

There is a bug caused by this change, selected nav will not change if switch nav by code instead of clicking.

@bggRGjQaUbCoE Can you file an issue to illustrate this problem?

@bggRGjQaUbCoE
Copy link

There is a bug caused by this change, selected nav will not change if switch nav by code instead of clicking.

@bggRGjQaUbCoE Can you file an issue to illustrate this problem?

@bleroux Thanks for your response, here i created an issue, #169249

@yoccu
Copy link

yoccu commented May 26, 2025

Probably this causes yet another bug. When MaterialApp's themeData is set to use splashFactory: NoSplash.splashFactory, the indicator does not update correctly. Insted of following the selection, it lacks one step behind (e.g. requires two taps on the same target to get the indicator shown up).

Code to reproduce with Flutter 3.34. Seems to affect at least Android platform.

import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      // Commenthing the following line off makes it work properly
      theme: ThemeData(colorSchemeSeed: Colors.white, splashFactory: NoSplash.splashFactory),
      home: MyScaffold(),
    );
  }
}

class MyScaffold extends StatefulWidget {
  const MyScaffold({super.key});

  @override
  State<StatefulWidget> createState() => _MyScaffoldState();
}

class _MyScaffoldState extends State<MyScaffold> {
  int _index = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('NavigationBar Bug'), centerTitle: true),
      body: Center(child: Text("index: $_index")),
      bottomNavigationBar: NavigationBar(
        selectedIndex: _index,
        onDestinationSelected: (newIndex) => setState(() => _index = newIndex),
        destinations: [
          NavigationDestination(
            icon: Icon(Icons.home),
            selectedIcon: Icon(Icons.home_filled),
            label: 'Home',
          ),
          NavigationDestination(
            icon: Icon(Icons.settings_outlined),
            selectedIcon: Icon(Icons.settings),
            label: 'Settings',
          ),
        ],
      ),
    );
  }
}

bleroux added a commit to bleroux/flutter that referenced this pull request May 27, 2025
bleroux added a commit to bleroux/flutter that referenced this pull request Jun 2, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 2, 2025
## Description

This PR reverts the change from [Fix NavigationBar indicator overlay
color](#164484) as it leads to
several regressions.

The change was very small: replacing a Container (which obscured the
overlay) with an Ink. Unfortunately this leads to some rendering issues
which seem related to the Ink painting not being fully in sync with the
animation logic implemented by `NavigationIndicator`.
I investigated this but did not find an obvious solution. So I would
prefer to revert #164484 as the
issue it fixed has less impact than the regression.
cc @justinmc for review and also in case you have some clue about why an
Ink would cause such problems compared to a Container.

## Related Issue

Fixes [[Flutter 3.32.0] Active NavigationBar item not selected when
switching items
programmatically](#169249)
Fixes [NavigationDrawer active indicator offset with
SvgPicture](#169436)
Fixes
#164484 (comment)

Reopens #163871
flutteractionsbot pushed a commit to flutteractionsbot/flutter that referenced this pull request Jun 5, 2025
…lutter#169497)

## Description

This PR reverts the change from [Fix NavigationBar indicator overlay
color](flutter#164484) as it leads to
several regressions.

The change was very small: replacing a Container (which obscured the
overlay) with an Ink. Unfortunately this leads to some rendering issues
which seem related to the Ink painting not being fully in sync with the
animation logic implemented by `NavigationIndicator`.
I investigated this but did not find an obvious solution. So I would
prefer to revert flutter#164484 as the
issue it fixed has less impact than the regression.
cc @justinmc for review and also in case you have some clue about why an
Ink would cause such problems compared to a Container.

## Related Issue

Fixes [[Flutter 3.32.0] Active NavigationBar item not selected when
switching items
programmatically](flutter#169249)
Fixes [NavigationDrawer active indicator offset with
SvgPicture](flutter#169436)
Fixes
flutter#164484 (comment)

Reopens flutter#163871
auto-submit bot pushed a commit that referenced this pull request Jun 5, 2025
…" (#170052)

This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:
What is the link to the issue this cherry-pick is addressing?

#169249
#169436

### Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples

NavigationBar active indicator animation gets stucked.

### Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

Visual glitch visible by users. In several scenarios, the active indicator for NavigationBar and NavigationDrawer is not properly painted (animation stucked half way or active color not reflecting the current state).

### Workaround:
Is there a workaround for this issue?

No

### Risk:
What is the risk level of this cherry-pick?

  - [ x ] Low

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

  - [ x ] Yes

### Validation Steps:
What are the steps to validate that this fix works?

Run the code sample from #169249.
This fix is a revert to a PR which landed in the current stable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NavigationBar lacks visual feedback when focused using keyboard on any platform, or when touched on mobile devices
5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy