Skip to content

Commit

Permalink
Fix: Return focus to feedback button (#1941)
Browse files Browse the repository at this point in the history
  • Loading branch information
Onokaev authored Jul 19, 2022
1 parent bda63a7 commit 51b9380
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/app/views/main-header/FeedbackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getTheme, IconButton, IIconProps, TooltipHost } from '@fluentui/react';
import React, { useState } from 'react';
import { getTheme, IButton, IconButton, IIconProps, TooltipHost } from '@fluentui/react';
import React, { useState, useEffect } from 'react';
import { translateMessage } from '../../utils/translate-messages';
import { useSelector } from 'react-redux';
import FeedbackForm from '../query-runner/request/feedback/FeedbackForm';
Expand All @@ -17,6 +17,18 @@ export const FeedbackButton = () => {
const feedbackTitle = translateMessage('Feedback');
const content = <div style={{padding:'3px'}}>{translateMessage('Feedback')}</div>

const feedbackButtonRef = React.useRef<IButton>(null)
const isFirstRender = React.useRef(true);
useEffect( () => {
if (isFirstRender.current) {
isFirstRender.current = false;
return;
}
if(!enableSurvey){
feedbackButtonRef.current?.focus();
}
},[enableSurvey])

const feedbackIconStyles = {
root:{
height: '50px',
Expand Down Expand Up @@ -66,6 +78,7 @@ export const FeedbackButton = () => {
styles={feedbackIconStyles}
role={'button'}
disabled={enableSurvey}
componentRef={feedbackButtonRef}
/>
</TooltipHost>

Expand Down
1 change: 1 addition & 0 deletions src/app/views/main-header/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const MainHeader: React.FunctionComponent <MainHeaderProps> = (props: Mai
feedbackIconAdjustmentStyles, tenantIconStyles, moreInformationStyles,
tenantLabelStyle, tenantContainerStyle } = mainHeaderStyles(currentTheme, mobileScreen);


return (
<Stack tokens={sectionStackTokens}>
<Stack
Expand Down

0 comments on commit 51b9380

Please sign in to comment.