Skip to content

Commit

Permalink
fix(topology): catalog btn tooltip should not show if not needed (#1009)
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <thvo@redhat.com>
  • Loading branch information
Thuan Vo authored May 2, 2023
1 parent ed1f37c commit 96ec510
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/app/Topology/Actions/QuickSearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export const QuickSearchModal: React.FC<QuickSearchModalProps> = ({
titleIconVariant={QuickSearchIcon}
title={'Topology Entity Catalog'}
className={'topology__quick-search-modal'}
id={'topology-quick-search-modal'}
description={<div>Select an entity to add to view. {guide}</div>}
>
<QuickSearchPanel />
Expand Down
33 changes: 23 additions & 10 deletions src/app/Topology/Toolbar/QuickSearchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import { portalRoot } from '@app/utils/utils';

import { Button, Tooltip } from '@patternfly/react-core';
import * as React from 'react';
import QuickSearchIcon from '../Shared/QuickSearchIcon';
Expand All @@ -46,16 +46,29 @@ export interface QuickSearchButtonProps {
}

export const QuickSearchButton: React.FC<QuickSearchButtonProps> = ({ onClick, tooltipContent, ...props }) => {
const catalogRef = React.useRef<HTMLDivElement>(null);
const handleClick = React.useCallback(() => {
onClick();
catalogRef.current?.blur(); // Remove focus on the catalog button
}, [onClick]);

return (
<Tooltip {...props} content={tooltipContent} appendTo={portalRoot}>
<Button
variant="plain"
onClick={onClick}
className={'topology__quick-search-button'}
data-quickstart-id={'topology-catalog-btn'}
<div id="topology-quicksearch-btn-wrapper">
<Tooltip
{...props}
content={tooltipContent}
appendTo={() => document.getElementById('topology-quicksearch-btn-wrapper') || document.body}
>
<QuickSearchIcon />
</Button>
</Tooltip>
<Button
variant="plain"
onClick={handleClick}
style={{ padding: 0 }}
data-quickstart-id={'topology-catalog-btn'}
ref={catalogRef}
>
<QuickSearchIcon />
</Button>
</Tooltip>
</div>
);
};
4 changes: 0 additions & 4 deletions src/app/Topology/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ Below CSS rules only apply to Topology components
font-size: 1.1em !important;
}

.topology__quick-search-button {
padding: 0;
}

.topology__list-view__entity-details {
background-color: var(--pf-global--palette--white);
padding: 1em;
Expand Down

0 comments on commit 96ec510

Please sign in to comment.