-
Notifications
You must be signed in to change notification settings - Fork 77
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: normalize FormValidationOverlay usage in other components #1183
Conversation
Deploy preview for fundamental-react ready! Built with commit 1396409 |
@@ -143,8 +143,15 @@ Please ensure you are either using a visible \`FormLabel\` or an \`aria-label\` | |||
labelProps: PropTypes.object, | |||
/** Sets the `name` for the checkbox input */ | |||
name: PropTypes.string, | |||
/** Additional classes to apply to validation popover */ | |||
validationClassName: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should moving this prop to validationOverlayProps.className
be listed as a breaking change as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%! Good catch
document.body.innerHTML = ''; | ||
}); | ||
|
||
const getFormMessage = () => document.body.querySelector('.fd-popover__popper > div > .fd-form-message'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea or an alternative, I've seen tests that include
// Ensure the popper is accessible with enzyme
jest.mock('react-dom', () => {
const original = jest.requireActual('react-dom');
return {
...original,
createPortal: (node) => node,
};
});
so you can still access the elements via enzyme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, but I'd like to apply it globally in config/jest/setup.js
so we don't have some unit tests with it/some without. It makes 450 unit tests fail at the moment so I'll probably skip it on this pr 😆
|
||
const messageNode = getFormMessage(); | ||
|
||
expect(messageNode).toBeDefined(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure expect(null).toBeDefined()
passes. If querySelector
can't find an element it returns null
, so this expect will always pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well... crap haha bad unit test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one after this is going to have the same problem - I'll rework both
}); | ||
}); | ||
|
||
describe('Interactions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skvale Looks like you solved this exact problem in tooltip in widgets recently - I copied and applied what you did there to get this working 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I forgot to merge this as a breaking change 😞 |
@jbadan any chance we would use |
@bcullman We could try... but that prop was added 1 day before and removed 1 day after. We're most likely the only ones that noticed it came and went 😆 |
Description
validationOverlayProps
to all components that consumeFormValidationOverlay
:Checkbox
,FormInput
,FormTextArea
,Select
,InputGroup
,SearchInput
,Select
,StepInput
validationOverlayProp
in all consuming componentsvalidationOverlayProp.formMessageProps
also spread toFormMessage
when used inside component (outside ofValidationOverlay
- seeSelect
orSearchInput
). This way, if you are expectingFormMessage
to receive additional classes, it will whether it's inside the dropdown or as it's own popover. This will be useful in nui-widgets-lab for override Gateway theming colors._FormValidationOverlay
(not exported to consumers) now spreads additional props to the wrapping<div>
element viawrapperProps
. I couldn't use...rest
because that creates a rabbithole of problems with the wayPopover
is cloning elements. Possibly worth a followup, but is a ton of work and creates a pretty confusing output just for continuity sake.BREAKING CHANGES:
fd-list--has-message
class from Select's dropdown - it was adding unnecessary padding. It was a relic from before FormMessage rendered inside a PopovervalidationClassName
renamed and moved inside ofvalidationOverlayProps
, use likevalidationOverlayProps.className
There will be at least 2 additional prs for Select - 1 to add the ability to pass custom classes to each component, the second addressing #1159