Skip to content

Commit 940bd40

Browse files
authored
[BUGFIX] visualisation of highlighted text (#5678)
This PR fixes the visualisation of highlighted text in text and chat fields adding an id
1 parent e425c89 commit 940bd40

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

argilla-frontend/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ These are the section headers that we use:
2323
### Fixed
2424

2525
- Fixed redirection problems after users sign-in using HF OAuth. ([#5635](https://github.com/argilla-io/argilla/pull/5635))
26+
- Fixed highlighting of the searched text in text and chat fields ([#5678](https://github.com/argilla-io/argilla/pull/5678))
2627

2728
## [2.4.0](https://github.com/argilla-io/argilla/compare/v2.3.0...v2.4.0)
2829

argilla-frontend/components/features/annotation/container/fields/chat-field/ChatField.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="chat" :key="title">
33
<span class="chat__title" v-text="title" />
44
<div
5+
:id="`fields-content-${name}`"
56
class="chat__wrapper"
67
:class="checkIfAreLessThanTwoRoles ? '--simple' : '--multiple'"
78
>

argilla-frontend/components/features/annotation/container/fields/text-field/TextField.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</BaseButton>
1717
</BaseActionTooltip>
1818
</div>
19-
<div class="content-area --body1">
19+
<div :id="`fields-content-${name}`" class="content-area --body1">
2020
<MarkdownRenderer v-if="useMarkdown" :markdown="fieldText" />
2121
<Sandbox v-else-if="isHTML" :content="fieldText" />
2222
<div v-else :class="classes" v-html="fieldText" />

argilla-frontend/components/features/annotation/container/fields/useSearchTextHighlight.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ export const useSearchTextHighlight = (fieldId: string) => {
121121

122122
const highlightText = (searchText: string) => {
123123
const fieldComponent = document.getElementById(FIELD_ID_TO_HIGHLIGHT);
124-
if (!searchText || !fieldComponent) return;
125-
124+
if (!searchText || !fieldComponent) {
125+
CSS.highlights.delete(HIGHLIGHT_CLASS);
126+
return;
127+
}
126128
const ranges = createRangesToHighlight(fieldComponent, searchText);
127129

128130
CSS.highlights.set(HIGHLIGHT_CLASS, new Highlight(...ranges));

0 commit comments

Comments
 (0)