fix(core): prevent navigating when clicking doc title in ai chat (#13412)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Updated search result titles to remove special styling and clickable highlighting. * **Bug Fixes** * Improved consistency of click behavior by making entire search result items clickable, rather than just the title text. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -3,7 +3,7 @@ import { WithDisposable } from '@blocksuite/global/lit';
|
|||||||
import { PageIcon, SearchIcon } from '@blocksuite/icons/lit';
|
import { PageIcon, SearchIcon } from '@blocksuite/icons/lit';
|
||||||
import { ShadowlessElement } from '@blocksuite/std';
|
import { ShadowlessElement } from '@blocksuite/std';
|
||||||
import type { Signal } from '@preact/signals-core';
|
import type { Signal } from '@preact/signals-core';
|
||||||
import { css, html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import type { ToolResult } from './tool-result-card';
|
import type { ToolResult } from './tool-result-card';
|
||||||
@@ -27,12 +27,6 @@ interface DocKeywordSearchToolResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DocKeywordSearchResult extends WithDisposable(ShadowlessElement) {
|
export class DocKeywordSearchResult extends WithDisposable(ShadowlessElement) {
|
||||||
static override styles = css`
|
|
||||||
.doc-keyword-search-result-title {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor data!: DocKeywordSearchToolCall | DocKeywordSearchToolResult;
|
accessor data!: DocKeywordSearchToolCall | DocKeywordSearchToolResult;
|
||||||
|
|
||||||
@@ -60,12 +54,7 @@ export class DocKeywordSearchResult extends WithDisposable(ShadowlessElement) {
|
|||||||
let results: ToolResult[] = [];
|
let results: ToolResult[] = [];
|
||||||
try {
|
try {
|
||||||
results = this.data.result.map(item => ({
|
results = this.data.result.map(item => ({
|
||||||
title: html`<span
|
title: item.title,
|
||||||
class="doc-keyword-search-result-title"
|
|
||||||
@click=${() => this.onOpenDoc(item.docId)}
|
|
||||||
>
|
|
||||||
${item.title}
|
|
||||||
</span>`,
|
|
||||||
icon: PageIcon(),
|
icon: PageIcon(),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
this.peekViewService.peekView
|
this.peekViewService.peekView
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { WithDisposable } from '@blocksuite/global/lit';
|
|||||||
import { AiEmbeddingIcon, PageIcon } from '@blocksuite/icons/lit';
|
import { AiEmbeddingIcon, PageIcon } from '@blocksuite/icons/lit';
|
||||||
import { ShadowlessElement } from '@blocksuite/std';
|
import { ShadowlessElement } from '@blocksuite/std';
|
||||||
import type { Signal } from '@preact/signals-core';
|
import type { Signal } from '@preact/signals-core';
|
||||||
import { css, html, nothing } from 'lit';
|
import { html, nothing } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import type { DocDisplayConfig } from '../ai-chat-chips';
|
import type { DocDisplayConfig } from '../ai-chat-chips';
|
||||||
@@ -55,12 +55,6 @@ function parseResultContent(content: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DocSemanticSearchResult extends WithDisposable(ShadowlessElement) {
|
export class DocSemanticSearchResult extends WithDisposable(ShadowlessElement) {
|
||||||
static override styles = css`
|
|
||||||
.doc-semantic-search-result-title {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor data!: DocSemanticSearchToolCall | DocSemanticSearchToolResult;
|
accessor data!: DocSemanticSearchToolCall | DocSemanticSearchToolResult;
|
||||||
|
|
||||||
@@ -95,12 +89,7 @@ export class DocSemanticSearchResult extends WithDisposable(ShadowlessElement) {
|
|||||||
.results=${this.data.result
|
.results=${this.data.result
|
||||||
.map(result => ({
|
.map(result => ({
|
||||||
...parseResultContent(result.content),
|
...parseResultContent(result.content),
|
||||||
title: html`<span
|
title: this.docDisplayService.getTitle(result.docId),
|
||||||
class="doc-semantic-search-result-title"
|
|
||||||
@click=${() => this.onOpenDoc(result.docId)}
|
|
||||||
>
|
|
||||||
${this.docDisplayService.getTitle(result.docId)}
|
|
||||||
</span>`,
|
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
this.peekViewService.peekView
|
this.peekViewService.peekView
|
||||||
.open({
|
.open({
|
||||||
|
|||||||
Reference in New Issue
Block a user