Skip to content

Conversation

@TahaTesser
Copy link
Member

Fixes [A11y] Double Tap brings the Slider thumb to the center of the widget.

Description

When double tapping in talkback or voice over mode on mobile platform, the Slider thumb moves to the center of the widget and changes the Slider value unexpectedly. When the user expects to swipe or down to adjust the Slider thumb. When tapping the Slider should show overlay for 500 milliseconds to bring attention instead of the moving the thumb to the center of the widget.

Code sample

expand to view the code sample
import 'package:flutter/material.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double _sliderValue = 0.2;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(brightness: Brightness.dark),
      home: Scaffold(
        body: Center(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16),
            child: IntrinsicHeight(
              child: Slider(
                value: _sliderValue,
                onChanged: (double value) {
                  setState(() {
                    _sliderValue = value;
                  });
                },
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Note: Semantic node size is known issue aka green box in the demos.

Before

The demo uses swipe up and down gesture to adjust the Slider. However, when double tapped the thumb unexpectedly moves to the center of the widget.

VID_20241025180329.mp4

After

The demo uses swipe up and down gesture to adjust the Slider. When double tapped the overlay is shown briefly.

VID_20241025180241.mp4

Android Components

VID_20241025180439.mp4

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Oct 25, 2024
@TahaTesser TahaTesser marked this pull request as draft October 25, 2024 17:06
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

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.

@github-actions github-actions bot added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Oct 28, 2024
@TahaTesser TahaTesser marked this pull request as ready for review October 28, 2024 10:52
@TahaTesser TahaTesser force-pushed the fix_slider_a11y_tap branch 3 times, most recently from 77d470e to e8b5be8 Compare October 29, 2024 08:45
@github-actions github-actions bot added the a: text input Entering text in a text field or keyboard related problems label Oct 29, 2024
@TahaTesser TahaTesser removed the a: text input Entering text in a text field or keyboard related problems label Oct 29, 2024
@TahaTesser TahaTesser requested a review from QuncCccccc October 29, 2024 16:02
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
// Skip the Slider use case, it uses tap action without label on purpose.
// see ttps://github.com/flutter/flutter/pull/157601.
if (useCase.name != 'Slider') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not very sure whether we can modify the test like this. @hannah-hyj and @chunhtai are OOO, we can double check with them next week:)

Copy link
Member Author

@TahaTesser TahaTesser Oct 30, 2024

Choose a reason for hiding this comment

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

I'm also not sure but this guideline test doesn't really work for Slider. When testing the Android components Slider, it is tappable in a11y mode without changing the Slider value and shows overlay.

My fix overrides Semantic with action tap to show overlay but action tap require semantics label but an existing Slider test prevents this. So i decided to skip the a11y test itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. If the current behavior is intended, I think we can create an issue for the guideline and add a TODO here:)
CC: @chunhtai

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look right, the slider use case does assign a label to the slider, it should not have failed the test. Can you dump the semantics tree when run the a11y_assessment app? i suspect something is forming a node unexpectedly

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

So I try to understand the issue. It looks like ios that it will issue regular tap if there isn't a semantics tap. the regular tap taps the center of the slider causes it to change the value to the middle.

The code here is a workaround so that the ios thinks there is a semantics tap so that it won't issue regular tap. This seems to me it is something that we should fix in iOS embedding. More specifically here should return YES if this is a slider
https://github.com/flutter/engine/blob/e553cd61645fc9bb21e62055e75ccddb09b596eb/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm#L695

Copy link
Member Author

Choose a reason for hiding this comment

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

Tagging @bleroux who can help fix this in the engine side.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we agree the fix should be on the iOS side, I think we should close this pr

@github-actions github-actions bot removed the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Oct 31, 2024
@TahaTesser TahaTesser requested a review from chunhtai October 31, 2024 16:11
@Piinks
Copy link
Contributor

Piinks commented Nov 6, 2024

(Triage): Flyby comment, there are a bunch of failing checks.

@TahaTesser TahaTesser closed this Nov 7, 2024
@TahaTesser TahaTesser deleted the fix_slider_a11y_tap branch November 7, 2024 08:01
auto-submit bot pushed a commit to flutter/engine that referenced this pull request Nov 12, 2024
)

## Description

iOS fix [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter/flutter#156427) per instruction from flutter/flutter#157601 (comment)

I don't have a physical iOS device to double check, but using the iOS Simulator and accessibility tools, the behavior seems ok. Without this PR, the slider thumb goes to the center when clicking 'Activate', with this PR it does not :

https://github.com/user-attachments/assets/697acadd-7fb1-40a5-ba5a-b549cac381a1

## Related Issue

iOS fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter/flutter#156427)

## Tests

Adds 1 test.
auto-submit bot pushed a commit to flutter/engine that referenced this pull request Nov 14, 2024
## Description

Android fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter/flutter#156427). Similar to [the iOS engine fix](#56427).

Slider widget doesn't define a Semantics.onTap handler, so a double-click while in accessibility mode defaults to a regular tap down event to which _RenderSlider reacts by changing the slider value.

Adding a onTap callback on the framework side was tried in flutter/flutter#157601 but it breaks one accessibility guideline test, see flutter/flutter#157601 (comment)). 

See flutter/flutter#157601 (comment) for the reasoning to make the change at the engine level.

## Related Issue

Android fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter/flutter#156427).

## Tests

Adds 1 test.
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…tter/engine#56427)

## Description

iOS fix [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter#156427) per instruction from flutter#157601 (comment)

I don't have a physical iOS device to double check, but using the iOS Simulator and accessibility tools, the behavior seems ok. Without this PR, the slider thumb goes to the center when clicking 'Activate', with this PR it does not :

https://github.com/user-attachments/assets/697acadd-7fb1-40a5-ba5a-b549cac381a1

## Related Issue

iOS fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter#156427)

## Tests

Adds 1 test.
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…6452)

## Description

Android fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter#156427). Similar to [the iOS engine fix](flutter/engine#56427).

Slider widget doesn't define a Semantics.onTap handler, so a double-click while in accessibility mode defaults to a regular tap down event to which _RenderSlider reacts by changing the slider value.

Adding a onTap callback on the framework side was tried in flutter#157601 but it breaks one accessibility guideline test, see flutter#157601 (comment)). 

See flutter#157601 (comment) for the reasoning to make the change at the engine level.

## Related Issue

Android fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter#156427).

## Tests

Adds 1 test.
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[A11y] Double Tap brings the Slider thumb to the center of the widget.

4 participants