Skip to content

Make support for search suggestions more generic, supporting Excel comment mentions and Google Chrome location bar suggestions#14222

Merged
michaelDCurran merged 14 commits intomasterfrom
i13764
Oct 17, 2022
Merged

Make support for search suggestions more generic, supporting Excel comment mentions and Google Chrome location bar suggestions#14222
michaelDCurran merged 14 commits intomasterfrom
i13764

Conversation

@michaelDCurran
Copy link
Member

@michaelDCurran michaelDCurran commented Oct 8, 2022

Link to issue number:

Fixes #13772
Fixes #13764
Fixes #13522

Summary of the issue:

Description of user facing changes

  • NVDA will now report the selected suggestion when arrowing through suggestions when typing an @mention in a Microsoft Excel comment.
  • NVDA will report the selected suggestion or suggestion control (switch to tab, remove suggestion) in the Google Chrome location bar.

Description of development approach

Make support for suggestions on editable text fields more generic, allowing it to be supported in more places without having to specifically choose particular overlay classes.

This adds support for reporting @mention suggestions in Microsoft Excel comments, and reporting of suggestions and related controls in the Google Chrome location bar.

Specific changes:

  • IAccessible NVDAObject: implement the controllerFor property making use of IAccessible2 relations
  • NVDAObject: add an isDescendantOf method which should return True if the object this method is called on is a descendant of the given obj argument. The base method raises NotImplementedError. Efficient implementations for UIA and Ia2Web have been provided.
  • Implement event_selection on the base NVDAObject, which reports the object being selected, if the current focus is controlling an ancestor of the selected object. This replaces SuggestionListItem UIA NVDAObject's event_UIA_elementSelected logic. Now it is more generic, and works purely on tree topology, rather than checking the name and appModule etc.
  • Remove event_selection implementation from IAccessible NvDAObject as the base handles this now.
  • Add an event_controllerForchange method to the base NVDAObject which does nothing.
  • UIA NVDAObject: implement event_UIA_controllerforchange to directly call event_controllerforchange, allowing for more generic code, but still backwards compatibility for subclasses to still override event_UIA_controllerforchange if they need to.
  • behaviours:
    • Rename EditableTextWithSuggestions to InputFieldWithSuggestions and inherit directly from NVDAObject making this class more generic.
    • InputFieldWithSuggestions class: implement event_controllerForChange which will fire the suggestionsOpened and suggestionsClosed events based on whether there are objects in the controllerfor list. this code was taken from SearchField UIA NVDAObject's event_UIA_controllerforchange.
    • Rename EditableText to EditabletextBase
    • Add a replacement EditableTextWithSuggestions class that inherits from both InputFieldWithSuggestions and EditableTextBase
    • Add a replacement EditableText class which inherits from EditableTextwithSuggestions and EditableTextBase.
      Essentially all this builds suggestion support into EditableText, but keeps the EditableTextWithSuggestionsClass specifically available for compatibility.

Testing strategy:

Known issues with pull request:

  • Suggestion open and suggestion close sounds are not played for the Google Chrome location bar suggestions as IAccessible2 does not have a controllerForchange event. This feature would be nice, but probably not expected by users anyway.
  • UIA_invalidatedLayout event has not been abstracted, thus auto reporting of suggestion count is still only available in specific UIA situations such as Settings search. this could be addressed separately at a later date if possible.

Change log entries:

New features
Changes
Bug fixes

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

…the object this method is called on is a descendant of the given obj argument.

The base method raises NotImplementedError.
Efficient implementations for UIA and Ia2Web have been provided.
…lowing it to be supported in more places without having to specifically choose particular overlay classes.

This adds support for reporting @mention suggestions in Microsoft Excel comments, and reporting of suggestions and related controls in the Google Chrome location bar.
Specific changes:
* Implement event_selection on the base NVDAObject, which reports the object being selected, if the current focus is controlling an ancestor of the selected object. This replaces SuggestionListItem UIA NVDAObject's event_UIA_elementSelected logic. Now it is more generic, and works purely on tree topology, rather than checking the name and appModule etc.
* Remove event_selection implementation from IAccessible NvDAObject as the base handles this now.
* Add an event_controllerForchange method to the base NVDAObject which does nothing.
* UIA NVDAObject: implement event_UIA_controllerforchange to directly call event_controllerforchange, allowing for more generic code, but still backwards compatibility for subclasses to still override event_UIA_controllerforchange if they need to.
* behaviours:
	* Rename EditableTextWithSuggestions to InputFieldWithSuggestions and inherit directly from NVDAObject making this class more generic.
	* InputFieldWithSuggestions class: implement event_controllerForChange which will fire the suggestionsOpened and suggestionsClosed events based on whether there are objects in the controllerfor list. this code was taken from SearchField UIA NVDAObject's event_UIA_controllerforchange.
	* Rename EditableText to EditabletextBase
	* Add a replacement EditableTextWithSuggestions class that inherits from both InputFieldWithSuggestions and EditableTextBase
	* Add a replacement EditableText class which inherits from EditableTextwithSuggestions and EditableTextBase.
	Essentially all this builds suggestion support into EditableText, but keeps the EditableTextWithSuggestionsClass specifically available for compatibility.

 # Please enter the commit message for your changes. Lines starting
@michaelDCurran michaelDCurran marked this pull request as ready for review October 8, 2022 22:47
@michaelDCurran michaelDCurran requested a review from a team as a code owner October 8, 2022 22:47
@josephsl
Copy link
Contributor

josephsl commented Oct 8, 2022

Hi,

Preliminary test results: works well in People app where contacts are announced automatically (test condition: Windows App Essentials add-on is disabled). I'll take a look at code this weekend.

Thanks.

Copy link
Contributor

@josephsl josephsl left a comment

Choose a reason for hiding this comment

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

Should we mark empty classes as deprecated and targeted for removal in 2024.1? Also, I think it woudl be best to talk about NVDAObject.isDescendantOf and the reorganized class hierarchy in behaviors module somewhere in "changes for developers" section. Thanks.

@josephsl
Copy link
Contributor

josephsl commented Oct 8, 2022

By the way, for @jcsteh, do you think if the approach taken in this PR can be adopted for use in Firefox and other Mozilla products? I imagine it will help when reviewing suggestions in Firefox address bar.

CC @derekriemer in case you would like to employ this change in Notepad++ enhancements.

Thanks.

@jcsteh
Copy link
Contributor

jcsteh commented Oct 9, 2022

Firefox already exposes the controllerFor relation on the address bar. That should mean this already works, but I"m guessing it doesn't based on your comment and the fact that Firefox wasn't mentioned in the PR description.

Perhaps Firefox doesn't fire the selection event on the first item; I'd need to check. If that's true, the reason would be that the list gets shown with the item already selected, so we don't fire the selection event because it would be redundant given that it was always selected since the list came into existence. I can see why that's a problem for NVDA, but I'm also not really sure how to solve it without special casing or causing a bunch of redundant events elsewhere.

That said, per the ARIA spec for autocompletes, Firefox fires focus on the selected item when you use the up and down arrow keys, which would override this new code for items other than the first. I'd love to see this changed, but it can't be changed without breaking backwards compatibility all over the place. I've had an idea for a while to hack around this in NVDA, ignoring those focus events and instead keeping focus on the text box, but that's a much bigger and riskier change.

• Suggestion open and suggestion close sounds are not played for the Google Chrome location bar suggestions as IAccessible2 does not have a controllerForchange event.

It's worth noting that Firefox exposes the collapsed/expanded state on the address bar depending on whether the list is showing and fires a stateChange event when that changes. That seems like a reasonable proxy for the lack of a native controllerForChange event. Chrome doesn't expose the expanded/collapsed state, but it seems like something they might be willing to do.

This feature would be nice, but probably not expected by users anyway.

I'm curious as to why users wouldn't expect this. Is this simply because of the previous state of things or is there some broader reason here? It seems to me that the lack of consistency would be unexpected, particularly for new users.

@seanbudd
Copy link
Member

seanbudd commented Oct 9, 2022

@josephsl

Should we mark empty classes as deprecated and targeted for removal in 2024.1?

The current policy is that if aliases for deprecated objects can remain without a major maintenance cost, then they shouldn't be removed.

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

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

general approach looks good, only minor fixes/questions raised

@michaelDCurran
Copy link
Member Author

michaelDCurran commented Oct 10, 2022 via email

@josephsl
Copy link
Contributor

Hi,

Update: this PR also resolves #13772. Thanks.

michaelDCurran and others added 2 commits October 10, 2022 15:55
Co-authored-by: Sean Budd <sean@nvaccess.org>
@AppVeyorBot
Copy link

See test results for failed build of commit 0d477a32af

@seanbudd seanbudd marked this pull request as draft October 13, 2022 01:37
@michaelDCurran
Copy link
Member Author

@seanbudd have I missed any review actions from you here?

Co-authored-by: Leonard de Ruijter <leonardder@users.noreply.github.com>
Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

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

frustratingly I noticed my pending review never published

Co-authored-by: Sean Budd <sean@nvaccess.org>
@michaelDCurran michaelDCurran marked this pull request as ready for review October 17, 2022 00:04
@AppVeyorBot
Copy link

See test results for failed build of commit 5e6e0b3f60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants