feat: add close button to widget and fix Storybook v10 config#12
Merged
KARTIK-PANDEY-KP merged 3 commits intomainfrom Mar 10, 2026
Conversation
- Add X close button to top-right of HomePage header (non-inline only) - Wire onClose prop through ChatWidget → HomePage - Fix Storybook v10 compatibility: remove deprecated argTypesRegex, update backgrounds.options → backgrounds.values array format Resolves BRA2-1177 Made-with: Cursor
Made-with: Cursor
Contributor
Author
…lors Made-with: Cursor
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HomePageheader so the widget can be dismissed from the home viewonCloseprop throughChatWidget→HomePage(non-inline positions only, consistent with the chat view)preview.ts: remove deprecatedargTypesRegexaction, updatebackgrounds.options→backgrounds.valuesarray formatChanges
src/components/HomePage/HomePage.tsx— newonCloseprop + X button in headersrc/components/HomePage/HomePage.module.css—.headerTopRowlayout +.closeButtonstylessrc/components/ChatWidget/ChatWidget.tsx— passesonClosetoHomePage.storybook/preview.ts— Storybook v10 compatibility fixesTest plan
npm run storybook) and select PurpleTheme or NavyTheme storyposition="inline"storiesCloses BRA2-1177
Made with Cursor
Greptile Summary
This PR adds an X (close) button to the
HomePageheader and wires theonCloseprop throughChatWidget→HomePage, mirroring the existing pattern used byChatContainer. It also updates.storybook/preview.tsfor Storybook v10 compatibility by removing the deprecatedargTypesRegexaction and migrating from the oldbackgrounds.optionsobject format to the newbackgrounds.valuesarray format.Key changes:
HomePage.tsx— new optionalonCloseprop; conditionally renders an accessible<button aria-label="Close chat">in the header, wrapped in aheaderTopRowflex container alongside the existing agent infoHomePage.module.css—.headerTopRowflex layout and.closeButtonstyles (hover, active, focus-visible states)ChatWidget.tsx— passesonClose={isInline ? undefined : handleClose}toHomePage, consistent withChatContainer.storybook/preview.ts— Storybook v10 compatibility:backgrounds.options→backgrounds.valuesarray,initialGlobals.backgrounds.valuenow uses a hex string instead of a name string, and the deprecatedargTypesRegexaction is removedIssue found:
showCollapseButton=true(the default), the new header X button and the existing collapse chevron below the widget are both visible simultaneously with the samearia-label="Close chat". Screen readers encounter two identical accessible names, which is confusing. The collapse button's label should be differentiated (e.g."Minimize chat").Confidence Score: 4/5
aria-label="Close chat"between the new header X button and the existing collapse chevron when both are visible on the home view — a straightforward one-line fix.aria-labelshould be differentiated from the new HomePage close button's label.Important Files Changed
argTypesRegexaction config and migratesbackgrounds.options→backgrounds.valuesarray format;initialGlobals.backgrounds.valuenow correctly uses a hex string instead of a name string for Storybook v10 compatibility.onClosetoHomePage(guarded by!isInline), consistent withChatContainer. However, when on the home view withshowCollapseButton=true, both the new header X button and the existing collapse chevron share the samearia-label="Close chat", creating duplicate accessible names for screen readers.onCloseprop and conditionally renders an accessible X button in the header; wraps existingagentInfoin a newheaderTopRowflex container. Implementation looks clean and accessible..headerTopRowlayout and.closeButtonstyles with hover/active/focus-visible states; hover usesrgba(0,0,0,0.2)(consistent dark tint), active shrinks the button, andfocus-visibleadds a white outline for keyboard users.Sequence Diagram
sequenceDiagram participant User participant ChatWidget participant HomePage participant ChatContainer User->>ChatWidget: clicks toggle button ChatWidget->>ChatWidget: setIsOpen(true) ChatWidget->>ChatContainer: renders (currentView = 'chat') User->>ChatContainer: clicks back button ChatContainer->>ChatWidget: handleBack() ChatWidget->>ChatWidget: setCurrentView('home') ChatWidget->>HomePage: renders with onClose=handleClose User->>HomePage: clicks X button (header) HomePage->>ChatWidget: onClose() ChatWidget->>ChatWidget: setIsOpen(false) ChatWidget->>ChatWidget: renders ChatToggleButton Note over ChatWidget,HomePage: When showCollapseButton=true, collapse chevron<br/>below also shows aria-label="Close chat" (duplicate)Comments Outside Diff (2)
.storybook/preview.ts, line 1-5 (link)Action spies silently dropped after removing
argTypesRegexRemoving
actions: { argTypesRegex }is the right move for Storybook v10, but it means thaton*callback props —onSessionStart,onSessionEnd,onMessage,onError, and the newonClose— will no longer appear in the Actions panel for any story. In v10 the recommended replacement is to explicitly passfn()from@storybook/testas the default value for each action arg, either per-story or viameta.args.For example, in
ChatWidget.stories.tsx:Without this, developers lose the ability to observe callback invocations in the Actions panel during manual testing.
Prompt To Fix With AI
src/components/ChatWidget/ChatWidget.tsx, line 350-366 (link)Duplicate
aria-labelwhen home view is activeWhen
currentView === 'home'and!isInline && showCollapseButton(the default), both the new X button insideHomePageheader and this collapse button below the widget are rendered simultaneously — and both carryaria-label="Close chat". Screen readers will announce two identically-named interactive controls, which is confusing and violates WCAG 2.4.6 (Headings and Labels). Differentiating the two labels would fix this:Last reviewed commit: 1a7ffb2