-
Notifications
You must be signed in to change notification settings - Fork 279
fix(ui5-tokenizer): allow copy/cut of focused token when not selected #13452
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -720,10 +720,14 @@ class Tokenizer extends UI5Element implements IFormInputElement { | |
| e.preventDefault(); | ||
|
|
||
| const isCut = e.key.toLowerCase() === "x" || isDeleteShift(e); | ||
| const selectedTokens = this._tokens.filter(token => token.selected); | ||
| const focusedToken = selectedTokens.find(token => token.focused); | ||
| let selectedTokens = this._tokens.filter(token => token.selected); | ||
| const focusedToken = this._tokens.find(token => token.focused); | ||
|
|
||
| if (isCut) { | ||
| if (!selectedTokens.length && focusedToken) { | ||
| selectedTokens = [focusedToken]; | ||
| } | ||
|
|
||
| if (isCut && !this.readonly) { | ||
| const cutResult = this._fillClipboard(ClipboardDataOperation.cut, selectedTokens); | ||
|
Contributor
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. In the sample we can see the token is deleted before the clipboard is filled. Actually I tried how it worked before and it was buggy anyway -> if we have selected and focused token -> CUT -> it deletes without filling the clipboard, in the same time if selected token is not the focused, CUT does nothing. We can discuss it. |
||
|
|
||
| focusedToken && this.deleteToken(focusedToken); | ||
|
|
@@ -1079,7 +1083,7 @@ class Tokenizer extends UI5Element implements IFormInputElement { | |
| } | ||
|
|
||
| _fillClipboard(shortcutName: ClipboardDataOperation, tokens: Array<IToken>) { | ||
| const tokensTexts = tokens.filter(token => token.selected).map(token => token.text).join("\r\n"); | ||
| const tokensTexts = tokens.map(token => token.text).join("\r\n"); | ||
|
|
||
| // Async clipboard API (works in secure contexts - HTTPS/localhost) | ||
| if (navigator.clipboard?.writeText && window.isSecureContext) { | ||
|
|
||
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.
We can add test for the case when we have selected tokens and focused is not from the selected ones so its clear what should happen. I'm not sure that "should cut multiple selected tokens when Ctrl+X is pressed" is enough to clarify that.