Skip to content

Commit

Permalink
[BUGFIX] visualisation of highlighted text (#5678)
Browse files Browse the repository at this point in the history
This PR fixes the visualisation of highlighted text in text and chat
fields adding an id
  • Loading branch information
leiyre authored and frascuchon committed Nov 8, 2024
1 parent 3614bba commit 69df2bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions argilla-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ These are the section headers that we use:
### Fixed

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="chat" :key="title">
<span class="chat__title" v-text="title" />
<div
:id="`fields-content-${name}`"
class="chat__wrapper"
:class="checkIfAreLessThanTwoRoles ? '--simple' : '--multiple'"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</BaseButton>
</BaseActionTooltip>
</div>
<div class="content-area --body1">
<div :id="`fields-content-${name}`" class="content-area --body1">
<MarkdownRenderer v-if="useMarkdown" :markdown="fieldText" />
<Sandbox v-else-if="isHTML" :content="fieldText" />
<div v-else :class="classes" v-html="fieldText" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ export const useSearchTextHighlight = (fieldId: string) => {

const highlightText = (searchText: string) => {
const fieldComponent = document.getElementById(FIELD_ID_TO_HIGHLIGHT);
if (!searchText || !fieldComponent) return;

if (!searchText || !fieldComponent) {
CSS.highlights.delete(HIGHLIGHT_CLASS);
return;
}
const ranges = createRangesToHighlight(fieldComponent, searchText);

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

0 comments on commit 69df2bc

Please sign in to comment.