From 097d5d9e552c989f13970eaac9299fc0436abbe3 Mon Sep 17 00:00:00 2001 From: TJ Egan Date: Tue, 24 Aug 2021 11:33:09 +0200 Subject: [PATCH] fix(ListBox): add title attribute to selected item (#9399) * fix(ListBox): add title attribute to selected item * test(snapshot): update snapshots * fix(Dropdown): remove console log --- packages/react/src/components/ComboBox/ComboBox.js | 1 + packages/react/src/components/Dropdown/Dropdown.js | 1 + .../components/Dropdown/__snapshots__/Dropdown-test.js.snap | 3 +++ 3 files changed, 5 insertions(+) diff --git a/packages/react/src/components/ComboBox/ComboBox.js b/packages/react/src/components/ComboBox/ComboBox.js index 27ad2e56658e..af8d885bcc9b 100644 --- a/packages/react/src/components/ComboBox/ComboBox.js +++ b/packages/react/src/components/ComboBox/ComboBox.js @@ -306,6 +306,7 @@ const ComboBox = React.forwardRef((props, ref) => { aria-expanded={rootProps['aria-expanded']} aria-haspopup="listbox" aria-controls={inputProps['aria-controls']} + title={textInput?.current?.value} {...inputProps} {...rest} ref={mergeRefs(textInput, ref)} diff --git a/packages/react/src/components/Dropdown/Dropdown.js b/packages/react/src/components/Dropdown/Dropdown.js index 27ab32a1ea52..d72a8649ad6d 100644 --- a/packages/react/src/components/Dropdown/Dropdown.js +++ b/packages/react/src/components/Dropdown/Dropdown.js @@ -163,6 +163,7 @@ const Dropdown = React.forwardRef(function Dropdown( className={`${prefix}--list-box__field`} disabled={disabled} aria-disabled={disabled} + title={selectedItem ? itemToString(selectedItem) : label} {...toggleButtonProps} ref={mergeRefs(toggleButtonProps.ref, ref)}> diff --git a/packages/react/src/components/Dropdown/__snapshots__/Dropdown-test.js.snap b/packages/react/src/components/Dropdown/__snapshots__/Dropdown-test.js.snap index 0612f7662ee3..1507eea3e6b4 100644 --- a/packages/react/src/components/Dropdown/__snapshots__/Dropdown-test.js.snap +++ b/packages/react/src/components/Dropdown/__snapshots__/Dropdown-test.js.snap @@ -72,6 +72,7 @@ exports[`Dropdown should render 1`] = ` id="downshift-0-toggle-button" onClick={[Function]} onKeyDown={[Function]} + title="input" type="button" >