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

feat(fluentUI-migration): ActiontButton fluentui v8 to v9 migration #7401

Open
wants to merge 82 commits into
base: fluent-ui-v9-migration-main
Choose a base branch
from

Conversation

v-rakeshsh
Copy link
Contributor

@v-rakeshsh v-rakeshsh commented Jul 30, 2024

Details

Action Button migration from V8 to V9

V8 Component V9 Component Reference Link
Action Button Button https://react.fluentui.dev/?path=/docs/components-button-button--docs
Primary Button Button https://react.fluentui.dev/?path=/docs/components-button-button--docs
CommandBarButton Combination of Menu, MenuTrigger, MenuButton, MenuPopover, MenuList 1. MenuButton - https://react.fluentui.dev/?path=/docs/components-button-menubutton--docs 2. Menu - https://react.fluentui.dev/?path=/docs/components-menu-menu--docs 3. MenuList - https://react.fluentui.dev/?path=/docs/components-menu-menulist--docs
IconProps for Action Button and action button internally takes care of showing the icon Created a component src/common/icons/fluentui-v9-icons.tsx to consume @fluentui/react-icons icons Cell

Styling Improvements:

  • Updated the width property from 100% to auto for better layout flexibility in multiple snapshot files.
  • Added new CSS classes for better button and icon styling, including hover and focus states.
  • Adjusted font-weight to normal for better text consistency.

Component Enhancements:

  • Added FluentUIV9Icon import and updated the components to use the new icon.
  • Improved the components with new styles and updated its component structure to use Fluent UI v9 components.
Motivation
  1. Migrate Action Button of V8 to V9 Button in all locations of code.
  2. Changed types to align with V9 button.
  3. Changed styling to align with old UI.
  4. Fixed test cases to cover >90% coverage.
Context

UI locations for all the files are mentioned with images in below file:

ActionButtonComparison

Due to FluentUI V9 Migration there are slight differences between old and new Icons. PFA screenshots below.

  • More Actions, Collapse all Icons

image
image

  • Expand, Move to Assessment Icons

image
image

  • Export result, Save Assessment, Load Assessment, Start over Icons

image
image

  • File issue, Copy failure details Icons

image
image

Note :

  1. isNarrowMode property is added in details-view-command-bar.tsx and other related files to differentiate the rendering of button in normal mode and menu in minimize mode.
  2. SaveAssessmentDialog is now moved out of SaveAssessmentButton file as with v9 button migration to menu, dialog in narrow mode was not rendering as it was getting close once menu button is clicked.
  3. Accessibility test has a failure for aria-hidden-focus. There is an existing issue with fluentui and as per them these are Tabster dummy inputs and they must be added to the exception list. They are intentionally aria - hidden as their purpose is to redirect focus to the correct element right when they receive focus and not having aria - hidden will result in the screen readers choking starting to announce them.
    Please refer for more information on the error:[Bug]: Tablist - ARIA hidden element must not be focusable or contain focusable elements fluentui#25133
  4. Changed buttonRef: IRefObject; to ButtonRefFunction, as ButtonRefFunction can be used in future when we migrate the dialog to v9 from V8.
  5. Changed /load-assessment-button.tsx to functional component from class component so that i can consume makeStyles hooks, as hooks cannot be used in class components, hence converted to Functional component.
  6. Removed IPoint because its deprecated in latest Fluent UI V8.
  7. Removed expand-collapse-all-button.scss because to consume makeStyles hooks and to use V9 themes, hence created expand-collapse-all-button.-styles.tsx.

Technical Debt:
These will be take care in up coming PR for v8 to v9 migration.
IButton:

  1. We are stilling using IButton from v8 for ref object in src\DetailsView\components\details-view-command-bar.tsx, because when we tried to use useRef instead of IButton, we have converted the component from class to functional component to consume useRef hook.
  2. But after converting to functional component and using useRef, focus back to kebab button is not going in narrow mode when we close the dialog.

Card footer button scroll behaviour

  1. If multiple issues are shown in the card footer, when we expand all issues, and if we click on the first issue section button, scroll goes to the bottom of the page i.e, the focus goes to the last section.

Closing dialog focus issue

  1. In Narromode,When we open the dialog on click of export or save assessment or start over, and when we close the dialog, focus is not going back to the Kebab button, as dialog is still in v8, we will take care of this focus back issues during v9 dialog migration.

Focus style inconsistency

  1. We explicitly added focus styling for buttons to show focus like kebab button / buttons, after closing the file issue dialog, but when we use keyboard to navigate to these kebab or other buttons, browser default focus styles are getting applied, for which it might look thick border for keyboard focus, but on close of dialog, the focus goes to button with little thin border.

Pull request checklist

  • Addresses an existing issue: #0000
  • Ran yarn fastpass
  • Added/updated relevant unit test(s) (and ran yarn test)
  • Verified code coverage for the changes made. Check coverage report at: <rootDir>/test-results/unit/coverage
  • PR title AND final merge commit title both start with a semantic tag (fix:, chore:, feat(feature-name):, refactor:). See CONTRIBUTING.md.
  • (UI changes only) Added screenshots/GIFs to description above
  • (UI changes only) Verified usability with NVDA/JAWS

@v-rakeshsh v-rakeshsh requested a review from a team as a code owner July 30, 2024 06:45
@v-rakeshsh v-rakeshsh marked this pull request as draft July 30, 2024 06:45
@v-rakeshsh v-rakeshsh changed the base branch from main to fluent-ui-v9-migration-main July 30, 2024 11:45
@v-viyada v-viyada marked this pull request as ready for review August 29, 2024 16:42
[initState Outdated Show resolved Hide resolved
Copy link
Contributor

@madalynrose madalynrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a huge effort, well done! I have some questions about things I was confused about and didn't see obvious explanations for.

src/DetailsView/components/command-bar-buttons-menu.scss Outdated Show resolved Hide resolved
src/DetailsView/components/command-bar-buttons-menu.tsx Outdated Show resolved Hide resolved
src/DetailsView/components/save-assessment-button.tsx Outdated Show resolved Hide resolved
onClick={this.onClick}
aria-expanded={showContent}
>
{showContent ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to keep the established pattern of calculating values outside of the return statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @madalynrose agree, moved out of return , please re-review

@@ -112,7 +112,7 @@ describe('FailureInstancePanelControlTest', () => {
'ActionButton',
'DefaultButton',
]);
useOriginalReactElements('@fluentui/react-components', ['Link', 'Button']);
useOriginalReactElements('@fluentui/react-components', ['Link']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing strategy from fully rendering the Button and using a mocked component instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @madalynrose made changes, please re-review
image

Comment on lines 31 to 49
const userConfigMessageCreatorMock: IMock<UserConfigMessageCreator> =
Mock.ofType(UserConfigMessageCreator);
const assessmentActionMessageCreatorMock: IMock<AssessmentActionMessageCreator> =
Mock.ofType<AssessmentActionMessageCreator>();
const handleSaveAssesmentButtonClickMock =
Mock.ofType<(event: React.MouseEvent<any>) => void>();
const userConfigurationStoreData: UserConfigurationStoreData = {
showSaveAssessmentDialog: true,
} as UserConfigurationStoreData;
const propsStub: SaveAssessmentButtonProps = {
deps: {
getAssessmentActionMessageCreator: () => assessmentActionMessageCreatorMock.object,
userConfigMessageCreator: userConfigMessageCreatorMock.object,
},
download: 'download',
href: 'url',
userConfigurationStoreData,
handleSaveAssesmentButtonClick: handleSaveAssesmentButtonClickMock.object,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this no longer in a beforeEach block? It's good to make sure all of this stuff is reset before each test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @madalynrose updated and retested, please re-review
image

@@ -0,0 +1,82 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there fewer tests than when these tests lived in SaveAssessmentButton?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @madalynrose as we moved out SaveAssessmentDialog from save-assessment-button, hence dialog related tests and save assessment button tests are separated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but it appears that there are fewer total now. I compared across both files.

Times.atLeastOnce(),
);
});
it('dialog is hidden (dismissed) when "got it" button is clicked', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is missing

});

describe('on dialog disabled', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is missing

fireEvent.click(wrapper.getByRole('link'));
});

it('saves assessment without dialog (dialog is hidden)', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is missing

expect(getMockComponentClassPropsForCall(Dialog).hidden).toEqual(true);
});

it('should call saveAssessment on click', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants