Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
[terra-tag] Combobox throws error when integrated with Fusion Combo B…
Browse files Browse the repository at this point in the history
…ox (#3942)
  • Loading branch information
MadanKumarGovindaswamy authored Oct 19, 2023
1 parent 2b47580 commit 5e78324
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/terra-form-select/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Changed
* Changed `class` selector used for accessing input text with data-attribute in form select `combobox` and `tag`.
## 6.48.0 - (October 16, 2023)

* Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/terra-form-select/src/combobox/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class Menu extends React.Component {
// Detects if option is an "Add option" and provides accessible text
const active = this.menu.querySelector('[data-select-active]');
if (active && active.hasAttribute('data-terra-select-add-option')) {
const display = active.querySelector("[class*='display']").innerText;
const display = active.querySelector('[data-terra-add-option]') ? active.querySelector('[data-terra-add-option]').innerText : null;
visuallyHiddenComponent.current.innerText = display;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/terra-form-select/src/shared/_Option.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const Option = ({
aria-label={itemLabel}
>
{(isCheckable || isAddOption) && <span className={cx('icon')} />}
<span className={cx('display')}>{display}</span>
<span data-terra-add-option className={cx('display')}>{display}</span>
</li>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/terra-form-select/src/tag/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class Menu extends React.Component {
// Detects if option is an "Add option" and provides accessible text
const active = this.menu.querySelector('[data-select-active]');
if (active && active.hasAttribute('data-terra-select-add-option')) {
const display = active.querySelector("[class*='display']").innerText;
const display = active.querySelector('[data-terra-add-option]') ? active.querySelector('[data-terra-add-option]').innerText : null;
visuallyHiddenComponent.current.innerText = display;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ exports[`ClearOption correctly applies the theme context className 1`] = `
>
<span
className="display"
data-terra-add-option={true}
>
Clear
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ exports[`Menu correctly applies the theme context className 1`] = `
>
<span
className="display"
data-terra-add-option={true}
>
display
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exports[`Option correctly applies the theme context className 1`] = `
>
<span
className="display"
data-terra-add-option={true}
>
display
</span>
Expand All @@ -44,6 +45,7 @@ exports[`Option should render a default Option 1`] = `
>
<span
className="display"
data-terra-add-option={true}
>
display
</span>
Expand All @@ -62,6 +64,7 @@ exports[`Option should render a disabled Option 1`] = `
>
<span
className="display"
data-terra-add-option={true}
>
display
</span>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/terra-form-select/tests/wdio/select-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2517,4 +2517,19 @@ Terra.describeViewports('Select', ['tiny'], () => {
after(() => $('#root').click());
});
});

describe('Combobox Add New Option', () => {
before(() => {
browser.url('/raw/tests/cerner-terra-core-docs/form-select/is-touch-accessible-combobox');
});

it('should add new option in combo box', () => {
$('[data-terra-select]').click();
browser.keys(['N', 'e', 'w']);
$('[data-terra-add-option]').click();
expect($('[data-terra-add-option]')).toHaveTextContaining('Add "New"');
$('[data-terra-select]').click();
Terra.validates.element('Add New Option in combo box', { selector: '#root' });
});
});
});

0 comments on commit 5e78324

Please sign in to comment.