-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Allow hover target override for resource labels #230101
Changes from all commits
ffa30b8
f59bb66
f3e07c6
d0a7707
7c08f26
3072114
302f3ed
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ import { IHistoryNavigationWidget } from '../../../../base/browser/history.js'; | |
import { StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js'; | ||
import * as aria from '../../../../base/browser/ui/aria/aria.js'; | ||
import { Button } from '../../../../base/browser/ui/button/button.js'; | ||
import { IManagedHoverContentOrFactory } from '../../../../base/browser/ui/hover/hover.js'; | ||
import { IHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegate.js'; | ||
import { createInstantHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegateFactory.js'; | ||
import { renderLabelWithIcons } from '../../../../base/browser/ui/iconLabel/iconLabels.js'; | ||
|
@@ -672,9 +671,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge | |
} | ||
|
||
const widget = dom.append(container, $('.chat-attached-context-attachment.show-file-icons')); | ||
const label = this._contextResourceLabels.create(widget, { supportIcons: true, hoverDelegate }); | ||
const label = this._contextResourceLabels.create(widget, { supportIcons: true, hoverDelegate, hoverTargetOverrride: widget }); | ||
|
||
let hoverElement: IManagedHoverContentOrFactory; | ||
let ariaLabel: string | undefined; | ||
|
||
const file = URI.isUri(attachment.value) ? attachment.value : attachment.value && typeof attachment.value === 'object' && 'uri' in attachment.value && URI.isUri(attachment.value.uri) ? attachment.value.uri : undefined; | ||
|
@@ -685,7 +683,6 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge | |
const friendlyName = `${fileBasename} ${fileDirname}`; | ||
|
||
ariaLabel = range ? localize('chat.fileAttachmentWithRange', "Attached file, {0}, line {1} to line {2}", friendlyName, range.startLineNumber, range.endLineNumber) : localize('chat.fileAttachment', "Attached file, {0}", friendlyName); | ||
hoverElement = file.fsPath; | ||
|
||
label.setFile(file, { | ||
fileKind: FileKind.FILE, | ||
|
@@ -696,7 +693,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge | |
} else if (attachment.isImage) { | ||
ariaLabel = localize('chat.imageAttachment', "Attached image, {0}", attachment.name); | ||
|
||
hoverElement = dom.$('div.chat-attached-context-hover'); | ||
const hoverElement = dom.$('div.chat-attached-context-hover'); | ||
hoverElement.setAttribute('aria-label', ariaLabel); | ||
|
||
// Custom label | ||
|
@@ -722,22 +719,21 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge | |
} | ||
|
||
widget.style.position = 'relative'; | ||
if (!this.attachedContextDisposables.isDisposed) { | ||
this.attachedContextDisposables.add(this.hoverService.setupManagedHover(hoverDelegate, widget, hoverElement, { trapFocus: false })); | ||
} | ||
} else { | ||
const attachmentLabel = attachment.fullName ?? attachment.name; | ||
const withIcon = attachment.icon?.id ? `$(${attachment.icon.id}) ${attachmentLabel}` : attachmentLabel; | ||
label.setLabel(withIcon, undefined); | ||
|
||
ariaLabel = localize('chat.attachment', "Attached context, {0}", attachment.name); | ||
hoverElement = attachmentLabel; | ||
|
||
this.attachButtonAndDisposables(widget, index, attachment, hoverDelegate); | ||
} | ||
|
||
widget.tabIndex = 0; | ||
widget.ariaLabel = ariaLabel; | ||
if (!this.attachedContextDisposables.isDisposed) { | ||
this.attachedContextDisposables.add(this.hoverService.setupManagedHover(hoverDelegate, widget, hoverElement, { trapFocus: false })); | ||
} | ||
Comment on lines
-738
to
-740
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. Does this mean attachments won't get hovers anymore? 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. They do, as it is provided by the resource label. I had to add this initially to make sure that focusing an attachment would cause the hover to show because the focus index is on the parent element of the resource label which also has a hover. This is annoying, because even though there is already a hover on the child element, I had to create a hover on the parent element to make this work. This is why I would like to fix this with this PR or a different approach |
||
}); | ||
|
||
if (oldHeight !== container.offsetHeight && !isLayout) { | ||
|
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.
Don't we still need to pass delegate here?
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.
Actually, it is not needed because the label already provides the default hover behaviour and tabs don't need any special hover behaviour