Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Return focus to feedback button #1941

Merged
merged 6 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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