Skip to content

Commit

Permalink
fix: fix #form-row hash sum on caching context
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Jan 21, 2020
1 parent 1db3386 commit 2cfb274
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/dnb-ui-lib/src/components/form-row/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ export default class FormRow extends PureComponent {
validateDOMAttributes(this.props, params)

// check if context has changed, if yes, then update the cache
if (hashSum(this._cachedContext) !== hashSum(this.context)) {
this._cachedContext = this.context
const cacheSum = { ...this.context, ...this.props }
if (hashSum(this._cachedContext) !== hashSum(cacheSum)) {
this._cachedContext = cacheSum

const formRow = {
useId: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ describe('FormRow component', () => {
expect(Comp.find('legend').exists()).toBe(false)
})

it('should react correct on two states in row', () => {
const Comp = mount(
<Component {...props} disabled={false}>
<Input />
</Component>
)
Comp.setProps({ disabled: true })
expect(Comp.find('input').is('[disabled]')).toBe(true)
})

it('should validate with ARIA rules', async () => {
expect(await axeComponent(Comp)).toHaveNoViolations()
})
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-ui-lib/src/components/textarea/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export default class Textarea extends PureComponent {
this.props,
defaultProps,
this.context.formRow,
this.context.translation.DatePicker
this.context.translation.Textarea
)

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ export default class ToggleButton extends Component {
this.props,
defaultProps,
this.context, // internal context
context.formRow
context.formRow,
context.translation.ToggleButton
)

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class ToggleButtonGroup extends PureComponent {
this.props,
defaultProps,
this.context.formRow,
this.context.translation.DatePicker
this.context.translation.ToggleButton
)

const {
Expand Down

0 comments on commit 2cfb274

Please sign in to comment.