Skip to content
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

Slider onChangeEnd is never called when arrow keys are used. #123315

Closed
Tracked by #125329
git-n-pissed opened this issue Mar 23, 2023 · 11 comments · Fixed by #126896
Closed
Tracked by #125329

Slider onChangeEnd is never called when arrow keys are used. #123315

git-n-pissed opened this issue Mar 23, 2023 · 11 comments · Fixed by #126896
Labels
f: material design flutter/packages/flutter/material repository. found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on r: fixed Issue is closed as already fixed in a newer version

Comments

@git-n-pissed
Copy link

git-n-pissed commented Mar 23, 2023

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Click on the slider so it gains focus
  3. Use left and right arrow keys to change slider position
  4. Note that onChangeEnd is never called. Only tested on Windows 10.

Expected results: onChangeEnd should be called at the end of every slider change, regardless how it is triggered. With arrow keys, I would expect onChangeEnd to be called when the arrow key is released.

Actual results: onChangeEnd is never called when the arrow keys are used.

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const SliderApp());

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: SliderExample(),
    );
  }
}

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

  @override
  State<SliderExample> createState() => _SliderExampleState();
}

class _SliderExampleState extends State<SliderExample> {
  double _currentSliderValue = 20;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Slider')),
      body: Slider(
        value: _currentSliderValue,
        max: 100,
        divisions: 5,
        label: _currentSliderValue.round().toString(),
        onChanged: (double value) {
          setState(() {
            _currentSliderValue = value;
          });
        },
        onChangeEnd: (double value) {
          print('onChangeEnd');
        },
      ),
    );
  }
}
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Mar 23, 2023
@darshankawar
Copy link
Member

@git-n-pissed
Looking at the code sample, I see the onChangeEnd is not called anywhere:

Screenshot 2023-03-23 at 3 20 01 PM

Also, take a look at this SO link and see if it helps in your case.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 23, 2023
@git-n-pissed
Copy link
Author

git-n-pissed commented Mar 23, 2023

@git-n-pissed Looking at the code sample, I see the onChangeEnd is not called anywhere:

Screenshot 2023-03-23 at 3 20 01 PM

Also, take a look at this SO link and see if it helps in your case.

Apologizes, the code I provided was missing the closing bracket for onChanged. I have corrected the code and the issue is still as described in the OP.

Thank you for the SO link, but I do not believe adding a delay as suggested in that link will be helpful in this case since the onChangeEnd callback is not being called at all when the arrow keys are used on Windows.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 23, 2023
@darshankawar
Copy link
Member

Thanks for the update. I was able to replicate this on mobile platform (iOS). Upon running code sample and clicking on slider, the onChangeEnd is triggered, but then using arrow keys although the slider moves, but the said method isn't called.

stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.7.7, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.7.7 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2ad6cd72c0 (12 days ago), 2023-03-08 09:41:59 -0800
    • Engine revision 1837b5be5f
    • Dart version 2.19.4
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[!] Flutter (Channel master, 3.9.0-16.0.pre.42, on macOS 12.2.1 21D62
    darwin-x64, locale en-GB)
    • Flutter version 3.9.0-16.0.pre.42 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/dhs/documents/fluttersdk/flutter. Consider adding
      /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
      Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
      of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a8afbfa22e (47 minutes ago), 2023-03-24 00:00:20 -0400
    • Engine revision 1da070c57c
    • Dart version 3.0.0 (build 3.0.0-362.0.dev)
    • DevTools version 2.22.2
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/dhs/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 65.1.4
    • Dart plugin version 213.7228

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (3 available)
    • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
      • iOS 15.3.1 19D52
    • macOS (desktop)           • macos                                    •
      darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)              • chrome                                   •
      web-javascript • Google Chrome 109.0.5414.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
      
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar changed the title Slider onChangeEnd is never called when arrow keys are used (Windows) Slider onChangeEnd is never called when arrow keys are used. Mar 24, 2023
@darshankawar darshankawar added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 and removed in triage Presently being triaged by the triage team labels Mar 24, 2023
@dleyba042
Copy link
Contributor

Hi, I was looking into this issue and saw that using the arrow key only fires the onChanged callback and neither onChangeStart or onChangeEnd callback. I am brand new at trying to contribute, any tips on where I could look to resolve this? I am wondering if its somewhere in this slider class I am looking over or if it might be in the gestures package. Thanks for any guidance you can give.

@dleyba042
Copy link
Contributor

I have something that may work as a fix? I'm wondering what people think. here is a gif of it. Basically every time you press a key there is a call to onChangeStart, then onChanged is called like before, then onChangeEnd is called with the value of the spot you landed at. I did not implement something like a drag however, if you hold a key it will call all three callbacks per position switch.

@dleyba042
Copy link
Contributor

WorkingOnGitIssue

@dleyba042
Copy link
Contributor

@darshankawar, good morning, I was wondering if you could check out my comments on this issue and give feedback. Also, was wondering you had the ability to assign me this issue. Thanks for your time.

@dleyba042
Copy link
Contributor

@TahaTesser Hi, I noticed that you were assigned the umbrella of Slider issues. Is there a way you could assign this issue in particular to me?

@TahaTesser
Copy link
Member

@TahaTesser Hi, I noticed that you were assigned the umbrella of Slider issues. Is there a way you could assign this issue in particular to me?

@dleyba042

Hi, I recommend taking a look at another issue. This will be fixed part as part of a bigger project under #125329

@dleyba042
Copy link
Contributor

Thanks @TahaTesser just doing this for education purposes. I have begun to look and start working on fixes for other issues as well.

@TahaTesser TahaTesser removed their assignment May 23, 2023
auto-submit bot pushed a commit that referenced this issue May 24, 2023
…ard shortcuts (#126896)

fixes #123315
--------

This PR makes changes to the _actionHandler function used on the Slider.Dart Widget for Key Events. It ensures onChangeStart is called at the beginning of a Key Event and onChangeEnd at the end of one. This PR includes a test for the changes made.
I ran all existing tests after my changes were made and they passed.
@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label May 25, 2023
@github-actions
Copy link

github-actions bot commented Jun 8, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. found in release: 3.7 Found to occur in 3.7 found in release: 3.9 Found to occur in 3.9 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants