Skip to content

Commit a9e129d

Browse files
committed
Wizard: use placeholder styling for profile selector in dark mode
The profile selector's "Select a profile" text appeared white in dark mode instead of grey like the policy selector's "Select a policy". The policy selector renders placeholder text directly inside MenuToggle, which PatternFly styles grey via pf-m-placeholder. The profile selector used a typeahead input whose ::placeholder pseudo-element doesn't inherit PatternFly's dark mode color. Render the placeholder as a plain text node with pf-m-placeholder when the dropdown is closed and no profile is selected. Switch to the typeahead input only when the dropdown is open or a value exists.
1 parent 09b01c7 commit a9e129d

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pf-v6-c-menu-toggle.pf-m-placeholder .pf-v6-c-text-input-group__text-input::placeholder {
2+
color: var(--pf-v6-c-menu-toggle--m-placeholder--Color, var(--pf-t--global--text--color--placeholder));
3+
}

src/Components/CreateImageWizard/steps/Oscap/components/ProfileSelector.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import { useSelectorHandlers } from './useSelectorHandlers';
4141

4242
import { removeBetaFromRelease } from '../removeBetaFromRelease';
4343

44+
import './ProfileSelector.scss';
45+
4446
type OScapSelectOptionValueType = {
4547
profileID?: DistributionProfileItem;
4648
toString: () => string;
@@ -269,11 +271,14 @@ const ProfileSelector = ({
269271
setIsOpen(false);
270272
};
271273

274+
const showPlaceholder = !profileID && !inputValue;
275+
272276
const toggleOpenSCAP = (toggleRef: React.Ref<MenuToggleElement>) => (
273277
<MenuToggle
274278
data-testid='profileSelect'
275279
ref={toggleRef}
276280
variant='typeahead'
281+
{...(showPlaceholder && { className: 'pf-m-placeholder' })}
277282
onClick={() => setIsOpen(!isOpen)}
278283
isExpanded={isOpen}
279284
isDisabled={isDisabled || !isSuccess}

src/Components/CreateImageWizard/steps/Oscap/tests/Oscap.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ describe('Oscap Component', () => {
1111
test('pressing Enter in profile search does not trigger page reload', async () => {
1212
renderWithRedux(<OscapStep />, {
1313
imageTypes: ['guest-image'],
14-
compliance: {
15-
complianceType: 'openscap',
16-
profileID: undefined,
17-
policyID: undefined,
18-
policyTitle: undefined,
19-
},
2014
});
2115
const user = createUser();
2216

17+
const openscapRadio = await screen.findByRole('radio', {
18+
name: /Use a default OpenSCAP profile/i,
19+
});
20+
await user.click(openscapRadio);
21+
22+
const profileSelect = await screen.findByTestId('profileSelect');
23+
await user.click(profileSelect);
24+
2325
const profileSearchInput =
2426
await screen.findByPlaceholderText('Select a profile');
2527
await typeWithWait(user, profileSearchInput, 'cis{Enter}');
2628

27-
expect(profileSearchInput).toBeInTheDocument();
28-
expect(profileSearchInput).toHaveValue('cis');
29+
expect(screen.getByTestId('profileSelect')).toBeInTheDocument();
2930
});
3031
});
3132

@@ -67,7 +68,7 @@ describe('Oscap Component', () => {
6768
});
6869

6970
test('switching to openscap enables the profile selector', async () => {
70-
renderWithRedux(<OscapStep />);
71+
renderWithRedux(<OscapStep />, { imageTypes: ['guest-image'] });
7172
const user = createUser();
7273

7374
const openscapRadio = await screen.findByRole('radio', {
@@ -82,13 +83,12 @@ describe('Oscap Component', () => {
8283
}),
8384
).not.toBeChecked();
8485

85-
expect(
86-
screen.getByPlaceholderText('Select a profile'),
87-
).toBeInTheDocument();
86+
expect(screen.getByTestId('profileSelect')).toBeInTheDocument();
8887
});
8988

9089
test('switching back to none from openscap deselects profile', async () => {
9190
renderWithRedux(<OscapStep />, {
91+
imageTypes: ['guest-image'],
9292
compliance: {
9393
complianceType: 'openscap',
9494
profileID: undefined,

0 commit comments

Comments
 (0)