-
Notifications
You must be signed in to change notification settings - Fork 698
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
Exclude MoreButton if Not using PrimaryCommands #6044
Changes from all commits
0f30807
7c4bceb
253fa2b
22e0742
40e97fa
aa7c4ce
69ff35c
330c5f7
8780178
a672e23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -678,7 +678,7 @@ void CommandBarFlyoutCommandBar::UpdateTemplateSettings() | |
collapsedWidth = static_cast<float>(expandedWidth); | ||
} | ||
|
||
flyoutTemplateSettings->WidthExpansionDelta(collapsedWidth - expandedWidth); | ||
flyoutTemplateSettings->WidthExpansionDelta(0); | ||
flyoutTemplateSettings->WidthExpansionAnimationStartPosition(-flyoutTemplateSettings->WidthExpansionDelta() / 2.0); | ||
flyoutTemplateSettings->WidthExpansionAnimationEndPosition(-flyoutTemplateSettings->WidthExpansionDelta()); | ||
flyoutTemplateSettings->ContentClipRect({ 0, 0, static_cast<float>(expandedWidth), primaryItemsRootDesiredSize.Height }); | ||
|
@@ -896,7 +896,9 @@ void CommandBarFlyoutCommandBar::PopulateAccessibleControls() | |
m_verticallyAccessibleControls.Clear(); | ||
} | ||
|
||
for (winrt::ICommandBarElement const& command : PrimaryCommands()) | ||
const auto primaryCommands = PrimaryCommands(); | ||
|
||
for (winrt::ICommandBarElement const& command : primaryCommands) | ||
{ | ||
if (auto const& commandAsControl = command.try_as<winrt::Control>()) | ||
{ | ||
|
@@ -907,8 +909,11 @@ void CommandBarFlyoutCommandBar::PopulateAccessibleControls() | |
|
||
if (auto const& moreButton = m_moreButton.get()) | ||
{ | ||
m_horizontallyAccessibleControls.Append(moreButton); | ||
m_verticallyAccessibleControls.Append(moreButton); | ||
if (primaryCommands.Size() > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the primary commands size is reduced from 1 to 0? what about if its increased from 0 to 1? do we have the appropriate code in place to make sure that the more button is added or removed based on this? Can we add a test for these scenarios? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
{ | ||
m_horizontallyAccessibleControls.Append(moreButton); | ||
m_verticallyAccessibleControls.Append(moreButton); | ||
} | ||
} | ||
|
||
for (winrt::ICommandBarElement const& command : SecondaryCommands()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -992,5 +992,97 @@ public void VerifyDynamicSecondaryCommandLabel() | |
Verify.AreEqual(finalBoundingRectangle.Height, initialBoundingRectangle.Height); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void VerifyIsFlyoutKeyboardAccessibleWithNoPrimaryCommands() | ||
{ | ||
if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) | ||
{ | ||
Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2"); | ||
return; | ||
} | ||
|
||
using (var setup = new CommandBarFlyoutTestSetupHelper()) | ||
{ | ||
Button showCommandBarFlyoutButtonWithNoPrimaryCommands = FindElement.ByName<Button>("Show CommandBarFlyout with no primary commands"); | ||
|
||
Log.Comment("Tap on a button to show the CommandBarFlyout."); | ||
showCommandBarFlyoutButtonWithNoPrimaryCommands.InvokeAndWait(); | ||
|
||
Button undoButton6 = FindElement.ById<Button>("UndoButton6"); | ||
var undoButtonElement = AutomationElement.FocusedElement; | ||
Verify.AreEqual(undoButtonElement.Current.AutomationId, undoButton6.AutomationId); | ||
|
||
KeyboardHelper.PressKey(Key.Up); | ||
Wait.ForIdle(); | ||
|
||
if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone3)) | ||
{ | ||
// rs2 does not loop through menuflyout items, so focus stays on the first button. | ||
Log.Comment("Press Up key to make sure it does not go to hidden controls."); | ||
Verify.AreEqual(undoButtonElement.Current.AutomationId, undoButton6.AutomationId); | ||
} | ||
else | ||
{ | ||
Log.Comment("Press Up key to make sure commands loops focus to last secondary command: Favorite."); | ||
Button favoriteToggleButton6 = FindElement.ById<Button>("FavoriteToggleButton6"); | ||
var favoriteToggleElement = AutomationElement.FocusedElement; | ||
Verify.AreEqual(favoriteToggleElement.Current.AutomationId, favoriteToggleButton6.AutomationId); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void VerifyAddPrimaryCommandsDynamically() | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test doesn't test the removal of a primary command, only the addition of one. More importantly, I wouldn't expect the behavior to fail when you change the number of commands in the CBF while it is closed. The bug I called out in the product code would only happen if you change the number of commands while the flyout is open. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a scenario where the number of commands will change while the flyout is open, since CBF is a flyout and transient by design. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline. Test case is updated to be adding PrimaryCommands dynamically. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For completeness removing the last primary command could also be tested. It uses what looks like the same code path though so maybe it is fine. |
||
if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) | ||
{ | ||
Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2"); | ||
return; | ||
} | ||
|
||
using (var setup = new CommandBarFlyoutTestSetupHelper()) | ||
{ | ||
Button showCommandBarFlyoutButton = FindElement.ByName<Button>("Show CommandBarFlyout with no primary commands"); | ||
ToggleButton addPrimaryCommandDynamicallyCheckBox = FindElement.ById<ToggleButton>("AddPrimaryCommandDynamicallyCheckBox"); | ||
ToggleButton clearPrimaryCommandsCheckBox = FindElement.ById<ToggleButton>("ClearPrimaryCommandsCheckBox"); | ||
ToggleButton primaryCommandDynamicallyAddedCheckBox = FindElement.ById<ToggleButton>("PrimaryCommandDynamicallyAddedCheckBox"); | ||
Edit dynamicLabelTimerIntervalTextBox = new Edit(FindElement.ById("DynamicLabelTimerIntervalTextBox")); | ||
Edit dynamicLabelChangeCountTextBox = new Edit(FindElement.ById("DynamicLabelChangeCountTextBox")); | ||
|
||
Log.Comment("Setting DynamicLabelTimerIntervalTextBox to 1s"); | ||
dynamicLabelTimerIntervalTextBox.SetValue("1000"); | ||
|
||
Log.Comment("Setting DynamicLabelChangeCountTextBox to 1 single change"); | ||
dynamicLabelChangeCountTextBox.SetValue("1"); | ||
Wait.ForIdle(); | ||
|
||
Log.Comment("Set Flyout6 to add Primary Commands dynamically"); | ||
addPrimaryCommandDynamicallyCheckBox.Check(); | ||
Wait.ForIdle(); | ||
|
||
Log.Comment("Invoke FlyoutTarget 6 to Show CommandBarFlyout with no primary commands"); | ||
showCommandBarFlyoutButton.Click(); | ||
|
||
Log.Comment("Waiting for SecondaryCommandDynamicLabelChangedCheckBox becoming checked indicating the asynchronous Label property change occurred"); | ||
primaryCommandDynamicallyAddedCheckBox.GetToggledWaiter().Wait(); | ||
Wait.ForIdle(); | ||
|
||
KeyboardHelper.PressKey(Key.Tab); | ||
Wait.ForIdle(); | ||
|
||
KeyboardHelper.PressKey(Key.Right); | ||
Wait.ForIdle(); | ||
|
||
Log.Comment("Verifying Primary Commands is added and MoreButton is actionable"); | ||
|
||
Button moreButton = FindElement.ById<Button>("MoreButton"); | ||
var moreButtonElement = AutomationElement.FocusedElement; | ||
Verify.AreEqual(moreButtonElement.Current.AutomationId, moreButton.AutomationId); | ||
|
||
Log.Comment("Dismissing flyout"); | ||
KeyboardHelper.PressKey(Key.Escape); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change, but if @llongley or someone else does that is good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought there was a need for a nonzero value for this, but Karen said that she tested all of the scenarios and they all continue to look right, so if that's the case it seems OK to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When PrimaryCommands are being loaded dynamically, it causes a weird crop issue that is caused by a negative
WidthExpansionDelta
. Setting it to 0 fixes this specific use case. Upon investigation, it seems a non-zeroWidthExpansionDelta
is only for when SecondaryCommands is collapsed, and the width of primaryCommands is less than the width of SecondaryCommands, so the flyout expands to the full width when opening the secondaryCommands.However, setting it to 0 doesn't seem to break that scenario. This may be because CBF no longer has the expanding animation. I manually all scenarios with and without the
WidthExpansionDelta
change, and it doesn't change or break anything.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CBF does have the expanding animation still though, there is a button for it on the CommandBarFlyout test page labeled "Show expanding CommandBarFlyout"
This is the behavior before this change:
PreChange.mp4
and this is the behavior after the change
PostChange.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I now see a subtle expanding animation that is missing from the update. I think the appropriate action is to revert the hardcoding of ExpansionWidthDelta, and fix the dynamically adding primary buttons in a separate fix. It is beyond the scope of the original accessibility bug to begin with.