Skip to content

Commit

Permalink
update code structure
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <tygao@amazon.com>
  • Loading branch information
raintygao committed Jun 7, 2024
1 parent 3665669 commit e78b599
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/hooks/use_patch_fixed_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { useEffect, useRef } from 'react';
import { useEffect } from 'react';

import { useCore } from '../contexts/core_context';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from '../../../../src/core/public';
Expand Down Expand Up @@ -35,7 +35,7 @@ export const usePatchFixedStyle = () => {
};

function updateHeadStyle(config: ISidecarConfig, text?: Text) {
let css = '';
let css: string;
if (!text) return;

if (
Expand Down Expand Up @@ -79,9 +79,11 @@ function updateHeadStyle(config: ISidecarConfig, text?: Text) {
}
`;
}
} else {
// If sidecar closes/hides or docked mode changes to takeover, we will set css empty to remove patch style and update.
css = '';
}

// If sidecar closes or docked direction change to takeover mode, we will keep css empty to remove patch style and update.
requestAnimationFrame(() => {
text.textContent = css;
});
Expand Down

0 comments on commit e78b599

Please sign in to comment.