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

Ensure settings are scrolled to using tab navigation #12300

Merged
merged 9 commits into from
Apr 21, 2021
Merged

Conversation

seanbudd
Copy link
Member

Link to issue number:

Closes #12224

Summary of the issue:

Navigating through settings using tabbing does not visually scroll to the focused control.

wxPython ScrolledPanels calculate the position to scroll to based on the relative position to a focus elements parent, rather than the relative position to the ScrolledPanel itself.

When fixing right-to-left issues in #12181, another layer of nesting was introduced for controls in our settings panels, which caused the controls to no longer get scrolled to.

Description of how this pull request fixes the issue:

A patched version of ScrolledPanel is created, which calculates relative position to the ScrolledPanel. A PR to wxPython has been created which implements this fix: wxWidgets/Phoenix#1950.

Testing strategy:

Ensure tabbing through long SettingsPanels such as "Document Formatting" scrolls the panel correctly.

Known issues with pull request:

None

Change log entry:

None, fixes regression

Code Review Checklist:

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual tests.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.

@seanbudd seanbudd self-assigned this Apr 16, 2021
@seanbudd seanbudd added this to the 2021.1 milestone Apr 16, 2021
@AppVeyorBot
Copy link

See test results for failed build of commit 11634169e7

@CyrilleB79
Copy link
Collaborator

Hello

I have tested the snapshot in Doc formatting, Speech, Braille, Vision and Advanced panels.
Quite all seems OK.
The only issue that I have seen is the "Report formatting changes after the cursor (can cause a lag)" option in the Doc formatting panel. This option remains invisible in this build whereas it was OK in 2020.4.

@seanbudd
Copy link
Member Author

Thanks @CyrilleB79 - that issue seems to be from an unrelated cause so I have fixed it on #12307

Copy link
Contributor

@feerrenrut feerrenrut left a comment

Choose a reason for hiding this comment

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

Overall looks good. Just a few minor things.

Comment on lines 375 to 384
def ScrollChildIntoView(self, child: wx.Window) -> None:
"""
Uses the same logic as super().ScrollChildIntoView(self, child)
except cr = self.GetChildRectRelativeToSelf(child) instead of cr = GetRect()
"""
sppu_x, sppu_y = self.GetScrollPixelsPerUnit()
vs_x, vs_y = self.GetViewStart()
cr = self.GetChildRectRelativeToSelf(child)
clntsz = self.GetClientSize()
new_vs_x, new_vs_y = -1, -1
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love it if there was a way to avoid having to duplicate the majority of this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

how does this new logic look? I am not a fan of overriding this function but it makes the actual change that we are doing clearer.

source/gui/nvdaControls.py Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

See test results for failed build of commit a3954250c6

@AppVeyorBot
Copy link

See test results for failed build of commit 89a2c64a2e

"""
oldChildGetRectFunction = child.GetRect
child.GetRect = lambda: self.GetChildRectRelativeToSelf(child)
super().ScrollChildIntoView(child)
Copy link
Member

Choose a reason for hiding this comment

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

Could you please place the super call in a try block, and the next line in a finally block. This will ensure that the function will be set back to its original value even if super throws an exception.

@seanbudd seanbudd requested a review from a team as a code owner April 20, 2021 23:44
@seanbudd seanbudd dismissed feerrenrut’s stale review April 21, 2021 01:03

addressed changes requested

@seanbudd seanbudd merged commit bc8eb11 into master Apr 21, 2021
@seanbudd seanbudd deleted the fix-12224 branch April 21, 2021 01:04
Comment on lines +388 to +393
child.GetRect = lambda: self.GetChildRectRelativeToSelf(child)
try:
super().ScrollChildIntoView(child)
finally:
# ensure child.GetRect is reset properly even if super().ScrollChildIntoView throws an exception
child.GetRect = oldChildGetRectFunction
Copy link
Contributor

Choose a reason for hiding this comment

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

I avoided suggesting this because it's a little dangerous. If any of the other method calls within super().ScrollChildIntoView rely on the absolute value for rect for the child, this will be broken in a subtle way.
Worse, by the time we update wxPython, we may have forgotten about this.

Copy link
Member Author

Choose a reason for hiding this comment

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

child is only used once in super().ScrollChildIntoView, and that is to calculate the incorrect child.GetRect https://github.com/wxWidgets/Phoenix/blob/wxPython-4.1.1/wx/lib/scrolledpanel.py#L190. Do we only update wxPython with compatibility breaking releases? That way I can mark this as deprecated for 2022.1 so it won't get lost.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense that we only update on compat breaking releases. Let's mark it as deprecated.

@seanbudd seanbudd added the deprecated/2022.1 Label used to track deprecations due for removal in the 2022.1 release label Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated/2022.1 Label used to track deprecations due for removal in the 2022.1 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting panels do not scroll automatically [Alpha regression]
5 participants