Skip to content

fix: option key does not work in addClickShortCut() method - #16086

Merged
czp13 merged 21 commits into
mainfrom
7798-option-key-does-not-work-in-addclickshortcut-method
Mar 13, 2023
Merged

czp13 merged 21 commits into
mainfrom
7798-option-key-does-not-work-in-addclickshortcut-method

Conversation

@czp13

@czp13 czp13 commented Mar 1, 2023 •

Copy link
Copy Markdown
Contributor

Description

This is a draft PR so do not merge please until we did not discuss it thoroughly.

Contex:
In Firefox, the option key is not working. The reason behind this as the browser implementing differently the KeyboardEvent when the option key is pushed, and when getModifierState() is called it will give back different true or false events based on whether you are using Chrome or Firefox.

The difference comes down to this:

Mozzila:

event.getModifierState('Alt') -> true
event.getModifierState('AltGraph') -> true

Chrome:

event.getModifierState('Alt') -> true
event.getModifierState('AltGraph') -> false

For more information:
Check to please the table for When getModifierState() returns true on Gecko? here:

Fixes # (issue)
#7798

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

@github-actions

github-actions Bot commented Mar 1, 2023 •

Copy link
Copy Markdown
Contributor

Test Results

   952 files  +1     952 suites  +1   59m 22s ⏱️ + 4m 19s
6 041 tests +5  6 006 ✔️ +5  35 💤 ±0  0 ❌ ±0 
6 299 runs  +5  6 257 ✔️ +5  42 💤 ±0  0 ❌ ±0 

Results for commit 9bf94a6. ± Comparison against base commit c55e06d.

♻️ This comment has been updated with latest results.

@czp13
czp13 requested a review from mshabarov March 2, 2023 12:32
@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Mar 6, 2023
czp13 and others added 3 commits March 6, 2023 16:55
- Added tests in ShortcutEventTest and created new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itselfes as the tests shows it is not handling all the cases properly
@czp13
czp13 marked this pull request as ready for review March 7, 2023 14:57
@czp13
czp13 requested a review from tepi March 8, 2023 08:56
tepi
tepi previously approved these changes Mar 8, 2023
@czp13
czp13 force-pushed the 7798-option-key-does-not-work-in-addclickshortcut-method branch from 5fcd8fa to 76fd8b9 Compare March 13, 2023 15:21
@czp13
czp13 enabled auto-merge (squash) March 13, 2023 16:10
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@czp13
czp13 disabled auto-merge March 13, 2023 17:18
@czp13
czp13 merged commit 36c5f9d into main Mar 13, 2023
@czp13
czp13 deleted the 7798-option-key-does-not-work-in-addclickshortcut-method branch March 13, 2023 17:29
vaadin-bot pushed a commit that referenced this pull request Mar 13, 2023
* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
vaadin-bot pushed a commit that referenced this pull request Mar 13, 2023
* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
vaadin-bot added a commit that referenced this pull request Mar 13, 2023
…16250)

* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>

Co-authored-by: czp13 <61667986+czp13@users.noreply.github.com>
vaadin-bot added a commit that referenced this pull request Mar 13, 2023
…16251)

* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>

Co-authored-by: czp13 <61667986+czp13@users.noreply.github.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

Hi @czp13 and @czp13, when i performed cherry-pick to this commit to 2.9, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 36c5f9d
error: could not apply 36c5f9d... fix: option key does not work in addClickShortCut() method (#16086)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

vaadin-bot pushed a commit that referenced this pull request Mar 14, 2023
* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

Hi @czp13 and @czp13, when i performed cherry-pick to this commit to 2.8, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 36c5f9d
error: could not apply 36c5f9d... fix: option key does not work in addClickShortCut() method (#16086)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

vaadin-bot pushed a commit that referenced this pull request Mar 14, 2023
* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
vaadin-bot added a commit that referenced this pull request Mar 14, 2023
…16254)

* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>

Co-authored-by: czp13 <61667986+czp13@users.noreply.github.com>
vaadin-bot added a commit that referenced this pull request Mar 15, 2023
…CP: 9.0) (#16255)

* fix: option key does not work in addClickShortCut() method (#16086)

* Investigations comments to relevant parts.
* formatted files with mvn formatter:format
* added potential solution, need to add covering tests as well (for triggering Alt, AltGraph, both of them shall work).
* removing comments, and potential solutions which will not be used anymore.
* Cleaned up comments to make it cleaner (ShortcutRegistration)
- Added tests in ShortcutEventTest and created a new test class for testing filterText generation ShortCutRegistrationFilterText,
- Some smaller comment/typo fixes in (Shortcuts),
- Changed the fix itself as the tests show it is not handling all the cases properly
* mvn formatter:format executed.
*fix test name typo.
* assertFalse refactor went wrong (double negation), I used assertTrue and forgot to remove the !.
Now it shall be good!
* after manual testing the code was fixed.
* fix the tests for covering the changes that happened in ShortCutRegistration.
* mvn formatter:format run once again.
* added JavaDoc for the test Reflection used util methods, and some small refactor to have inline variable.
* mvn formatter:format run once again + some new asserts in tets as well.
* cleanup the code based on Tepi's review, idea! (Thanks!)
* "&&&&".split("&&", Integer.MAX_VALUE) -> this will give back ["", "", ""], but without the second parameter, it would have not found these... So with this fix, we will cover more cases.
(https://stackoverflow.com/questions/18815911/string-split-and-dealing-with-duplicates)
* minor cleanup (Teppo)
---------
Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>

* Fix the code in ShortcutRegistration to compile in Java 9 as well (thanks @mshabarov).

---------

Co-authored-by: czp13 <61667986+czp13@users.noreply.github.com>
Co-authored-by: Peter Czuczor <czuczor@gmail.com>
czp13 added a commit that referenced this pull request Mar 23, 2023
…ndle more implementations of Key interface and fix browser differences. (#16276)(#16086)(CP: 2.8)  (#16362)

* fix: Mozilla Firefox vs chrome browser implementation differences for option key,
* chore: optimize getModifierKey method, to handle more implementations of Key interface: (#16276)
* Make this code:
.contains(new HashableKey(KeyModifier.ALT))
	to work for more universal cases:
.stream().anyMatch(key -> key.matches(Key.ALT.toString()));
It should work now for HashableKeys and for other Key implementations as well.
* Format the code and make it work for older Java versions as well.
* As Key.Alt actually will be a collection of keys (key and additional keys), we need to look for the "Alt" itself.
(Key ALT = Key.of("Alt", "AltLeft")
* chore: added covering tests as well for this cherry-picked improvement.
czp13 added a commit that referenced this pull request Mar 23, 2023
…ndle more implementations of Key interface and fix browser differences. (#16276)(#16086)(CP: 2.9)  (#16361)

* fix: Mozilla Firefox vs chrome browser implementation differences for option key,
* chore: optimize getModifierKey method, to handle more implementations of Key interface: (#16276)
* Make this code:
.contains(new HashableKey(KeyModifier.ALT))
	to work for more universal cases:
.stream().anyMatch(key -> key.matches(Key.ALT.toString()));
It should work now for HashableKeys and for other Key implementations as well.
* Format the code and make it work for older Java versions as well.
* As Key.Alt actually will be a collection of keys (key and additional keys), we need to look for the "Alt" itself.
(Key ALT = Key.of("Alt", "AltLeft")
* chore: added covering tests as well for this cherry-picked improvement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants