Skip to content

Commit

Permalink
fixed search highlighting. was only showing highlighted text w/o cont…
Browse files Browse the repository at this point in the history
…ext (elastic#132650)

Co-authored-by: mitodrummer <karlgodard@elastic.co>
  • Loading branch information
mitodrummer and mitodrummer authored May 20, 2022
1 parent 791ebfa commit 41635e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,19 @@ describe('ProcessTreeNode component', () => {
describe('Search', () => {
it('highlights text within the process node line item if it matches the searchQuery', () => {
// set a mock search matched indicator for the process (typically done by ProcessTree/helpers.ts)
processMock.searchMatched = '/vagrant';
processMock.searchMatched = '/vagr';

renderResult = mockedContext.render(<ProcessTreeNode {...props} />);

expect(
renderResult.getByTestId('sessionView:processNodeSearchHighlight').textContent
).toEqual('/vagrant');
).toEqual('/vagr');

// ensures we are showing the rest of the info, and not replacing it with just the match.
const { process } = props.process.getDetails();
expect(renderResult.container.textContent).toContain(
process?.working_directory + '\xA0' + (process?.args && process.args.join(' '))
);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function ProcessTreeNode({
});

// eslint-disable-next-line no-unsanitized/property
textRef.current.innerHTML = html;
textRef.current.innerHTML = '<span>' + html + '</span>';
}
}
}, [searchMatched, styles.searchHighlight]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export const useStyles = ({
fontSize: FONT_SIZE,
lineHeight: LINE_HEIGHT,
verticalAlign: 'middle',
display: 'inline-block',
},
};

Expand Down Expand Up @@ -165,6 +164,7 @@ export const useStyles = ({
paddingLeft: size.xxl,
position: 'relative',
lineHeight: LINE_HEIGHT,
marginTop: '1px',
};

const alertDetails: CSSObject = {
Expand Down

0 comments on commit 41635e2

Please sign in to comment.