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

feat(IText): deprecate KeyboardEvent#keyCode in favor of key #7865

Closed
wants to merge 15 commits into from

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Apr 5, 2022

  • deprecate keyCode (mdn states it is) in favor of key | code
  • support passing functions to keyMap
  • fix: modifier functions prior to non modifier in calling logic

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.07 |    76.06 |   86.29 |   82.79 |                                               
 fabric.js |   83.07 |    76.06 |   86.29 |   82.79 | ...,30140,30214,30225-30290,30413,30512,30748 
-----------|---------|----------|---------|---------|-----------------------------------------------

Copy link
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

nice and simple

else if (e.keyCode in keyMap) {
func = keyMap[e.keyCode];
}
else if ((e.key in this.ctrlKeysMapDown) && (e.ctrlKey || e.metaKey)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't the ctrl maps come before the general key maps?

Copy link
Member

Choose a reason for hiding this comment

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

eventually yes. Probably there was not overlapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No overlapping in fabric. I had in mind the dev wanting to override what happens when a ctrl modifier is active.
Current logic doesn't allow.

Copy link
Contributor Author

@ShaMan123 ShaMan123 Apr 29, 2022

Choose a reason for hiding this comment

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

a045103 fixes modifier priority

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.07 |    76.06 |   86.29 |   82.79 |                                               
 fabric.js |   83.07 |    76.06 |   86.29 |   82.79 | ...,30140,30214,30225-30290,30413,30512,30748 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123 ShaMan123 requested a review from melchiar April 5, 2022 07:43
@asturur
Copy link
Member

asturur commented Apr 5, 2022

keyCode is probably deprecated, important is that key is fully available in all supported browser.
Probably ie11 was the reason we were on keyCode.

Can we verify that? in case we don't need to support keyCode anymore.
Do the values between key and keyCode differ?

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Apr 5, 2022

They are totally different.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#browser_compatibility
All browsers support key and MDN officially suggests using it instead of the rest.
image

@ShaMan123
Copy link
Contributor Author

Now if I want to remove keyCode from this PR I will get a conflict with #7864 (This is the part I dislike about splitting PRs - but I do undersrand it's a must)

@stale
Copy link

stale bot commented Apr 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Apr 25, 2022
@ShaMan123 ShaMan123 added text and removed stale Issue marked as stale by the stale bot labels Apr 25, 2022
@asturur
Copy link
Member

asturur commented Apr 29, 2022

i think that if we want to duplicate deprecate keycode in favor of key, we should change the maps to have the key and we can leave keycode support for 1 major version with a dev warning.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.94 |    75.26 |   86.32 |   82.66 |                                               
 fabric.js |   82.94 |    75.26 |   86.32 |   82.66 | ...,30483,30557,30568-30633,30756,30855,31091 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.93 |    75.27 |   86.34 |   82.65 |                                               
 fabric.js |   82.93 |    75.27 |   86.34 |   82.65 | ...,30511,30585,30596-30661,30784,30883,31119 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.88 |     75.1 |   86.34 |    82.6 |                                               
 fabric.js |   82.88 |     75.1 |   86.34 |    82.6 | ...,30521,30595,30606-30671,30794,30893,31129 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.89 |    75.13 |   86.34 |   82.61 |                                               
 fabric.js |   82.89 |    75.13 |   86.34 |   82.61 | ...,30521,30595,30606-30671,30794,30893,31129 
-----------|---------|----------|---------|---------|-----------------------------------------------

in case wild languages and keyboards I am not aware of
@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.89 |    75.13 |   86.34 |   82.61 |                                               
 fabric.js |   82.89 |    75.13 |   86.34 |   82.61 | ...,30521,30595,30606-30671,30794,30893,31129 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.87 |    75.23 |   86.34 |   82.58 |                                               
 fabric.js |   82.87 |    75.23 |   86.34 |   82.58 | ...,30525,30599,30610-30675,30798,30897,31133 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.03 |    75.53 |   86.35 |   82.74 |                                               
 fabric.js |   83.03 |    75.53 |   86.35 |   82.74 | ...,30507,30581,30592-30657,30780,30879,31115 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.04 |    75.57 |   86.35 |   82.76 |                                               
 fabric.js |   83.04 |    75.57 |   86.35 |   82.76 | ...,30507,30581,30592-30657,30780,30879,31115 
-----------|---------|----------|---------|---------|-----------------------------------------------

src/mixins/itext_key_behavior.mixin.js Show resolved Hide resolved
else if (e.keyCode in keyMap) {
func = keyMap[e.keyCode];
}
else if ((e.key in this.ctrlKeysMapDown) && (e.ctrlKey || e.metaKey)) {
Copy link
Contributor Author

@ShaMan123 ShaMan123 Apr 29, 2022

Choose a reason for hiding this comment

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

a045103 fixes modifier priority

src/mixins/itext_key_behavior.mixin.js Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.16 |    76.17 |   85.79 |   82.89 |                                               
 fabric.js |   83.16 |    76.17 |   85.79 |   82.89 | ...,30892,30966,30977-31042,31165,31264,31500 
-----------|---------|----------|---------|---------|-----------------------------------------------

@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label Sep 21, 2022
@ShaMan123 ShaMan123 removed the stale Issue marked as stale by the stale bot label Sep 21, 2022
@ShaMan123 ShaMan123 mentioned this pull request Nov 26, 2022
@ShaMan123 ShaMan123 closed this Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants