Skip to content

8286204: [Accessibility,macOS,VoiceOver] VoiceOver reads the spinner value 10 as 1 when user iterates to 10 for the first time on macOS #3366

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;

import static javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY;
Expand Down Expand Up @@ -121,7 +122,11 @@ public void propertyChange(PropertyChangeEvent e) {
if (name.equals(ACCESSIBLE_CARET_PROPERTY)) {
selectedTextChanged(ptr);
} else if (name.equals(ACCESSIBLE_TEXT_PROPERTY)) {
valueChanged(ptr);
AccessibleContext thisAC = accessible.getAccessibleContext();
Accessible parentAccessible = thisAC.getAccessibleParent();
if (!(parentAccessible instanceof JSpinner.NumberEditor)) {
valueChanged(ptr);
}
} else if (name.equals(ACCESSIBLE_SELECTION_PROPERTY)) {
selectionChanged(ptr);
} else if (name.equals(ACCESSIBLE_TABLE_MODEL_CHANGED)) {
Expand Down
75 changes: 75 additions & 0 deletions test/jdk/javax/accessibility/TestJSpinnerAccessibility.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;

/*
* @test
* @bug 8286204
* @summary Verifies that VoiceOver announces the JSpinner's value correctly
* @requires os.family == "mac"
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual TestJSpinnerAccessibility
*/

public class TestJSpinnerAccessibility {
public static void main(String[] args) throws Exception {
String INSTRUCTIONS = """
Test UI contains a JSpinner with minimum value 0, maximum value 20
and current value 5. On press of up / down arrow, value will be
incremented / decremented by 1.

Follow these steps to test the behaviour:

1. Start the VoiceOver (Press Command + F5) application
2. Move focus on test window if it is not focused
3. Press Up / Down arrow to increase / decrease Spinner value
4. VO should announce correct values in terms of percentage
(e.g. For JSpinner's value 10, VO should announce 50%)
5. Press Pass if you are able to hear correct announcements
else Fail""";

PassFailJFrame.builder()
.title("TestJSpinnerAccessibility Instruction")
.instructions(INSTRUCTIONS)
.columns(40)
.testUI(TestJSpinnerAccessibility::createUI)
.build()
.awaitAndCheck();
}

private static JFrame createUI() {
JFrame frame = new JFrame("A Frame with JSpinner");
SpinnerModel spinnerModel = new SpinnerNumberModel(5, 0, 20, 1);
JSpinner spinner = new JSpinner(spinnerModel);
frame.getContentPane().add(spinner, BorderLayout.CENTER);
frame.setSize(200, 100);
return frame;
}
}