Skip to content

Commit

Permalink
Move selectors to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Maja Grubic committed Sep 22, 2022
1 parent 0b127e4 commit e898297
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const getClasses = (template?: string, className?: string) => {
);
};

const KIBANA_CHROME_SELECTOR = '[data-test-subj="kibanaChrome"]';
const HEADER_GLOBAL_NAV_SELECTOR = '[data-test-subj="headerGlobalNav"]';

/**
* A thin wrapper around EuiPageTemplate with a few Kibana specific additions
*/
Expand All @@ -38,10 +41,10 @@ export const KibanaPageTemplateInner: FC<Props> = ({
const [offset, setOffset] = useState<number | undefined>();

useEffect(() => {
const kibanaChrome = document.querySelector('[data-test-subj="kibanaChrome"]') as HTMLElement;
const kibanaChrome = document.querySelector(KIBANA_CHROME_SELECTOR) as HTMLElement;
if (kibanaChrome) {
const kibanaChromeHeader = kibanaChrome.querySelector(
'[data-test-subj="headerGlobalNav"]'
HEADER_GLOBAL_NAV_SELECTOR
) as HTMLElement;
setOffset(kibanaChromeHeader?.offsetTop + kibanaChromeHeader?.offsetHeight);
}
Expand Down

0 comments on commit e898297

Please sign in to comment.