nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: laboratoriobridge/bold
Pull request #510 (2019-12-03 16:50:22)

Fix 'createNewItem' prop called on wrong change type events


Patch:
diff --git a/src/components/Select/SelectSingle/SelectDownshift.tsx b/src/components/Select/SelectSingle/SelectDownshift.tsx
index 090298c8f..96c362259 100644
--- a/src/components/Select/SelectSingle/SelectDownshift.tsx
+++ b/src/components/Select/SelectSingle/SelectDownshift.tsx
@@ -66,7 +66,11 @@ export function SelectDownshift<T>(props: SelectDownshiftProps<T>) {
   }, [props.items])
 
   const handleStateChange = (changes: StateChangeOptions<T>, downshift: ControllerStateAndHelpers<T>) => {
-    if (createNewItem && changes.hasOwnProperty('inputValue')) {
+    if (
+      createNewItem &&
+      changes.hasOwnProperty('inputValue') &&
+      changes.type === Downshift.stateChangeTypes.changeInput
+    ) {
       rest.onChange && rest.onChange(createNewItem(changes.inputValue), getStateAndHelpers(downshift))
     }
 


Test patch:
diff --git a/src/components/Select/SelectSingle/SelectSingle.test.tsx b/src/components/Select/SelectSingle/SelectSingle.test.tsx
index cd1e79c90..cd571d0aa 100644
--- a/src/components/Select/SelectSingle/SelectSingle.test.tsx
+++ b/src/components/Select/SelectSingle/SelectSingle.test.tsx
@@ -1,9 +1,7 @@
 import { fireEvent, render } from '@testing-library/react'
 import { resetIdCounter } from 'downshift'
 import React from 'react'
-
 import en from '../../../i18n/locales/en-US'
-
 import { DefaultItemType, SelectSingle, SelectSingleProps } from './SelectSingle'
 
 jest.mock('../../../util/string')
@@ -186,4 +184,14 @@ describe('createNewItem', () => {
     fireEvent.focus(container.querySelector('input'))
     expect(container.querySelector('ul')).toBeTruthy()
   })
+  it('should call "createNewItem" only when change type is "changeInput"', async () => {
+    const createNewItem = jest.fn(text => ({ label: text } as any))
+    const { rerender } = render(
+      <SelectTest id='foo' createNewItem={createNewItem} value={items[0]} onChange={jest.fn()} />
+    )
+    rerender(
+      <SelectTest id='foo' createNewItem={createNewItem} value={{ ...items[0], label: 'a' }} onChange={jest.fn()} />
+    )
+    expect(createNewItem).not.toHaveBeenCalled()
+  })
 })
Repository: laboratoriobridge/bold
Pull request #563 (2020-04-16 17:31:12)

Fix checkbox min-width


Patch:
diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx
index 47f24c0ca..06949b548 100644
--- a/src/components/Checkbox/Checkbox.tsx
+++ b/src/components/Checkbox/Checkbox.tsx
@@ -46,6 +46,7 @@ export const createStyles = (theme: Theme) => ({
     transition: 'all .2s ease',
     verticalAlign: 'middle',
     width: 24,
+    minWidth: 24,
   } as CSSProperties,
   label: {
     marginLeft: '0.5rem',


Test patch:
diff --git a/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap b/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap
index ace7ff183..c801787fa 100644
--- a/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap
+++ b/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap
@@ -24,6 +24,7 @@ exports[`Checkbox should render correctly 1`] = `
   transition: all .2s ease;
   vertical-align: middle;
   width: 24px;
+  min-width: 24px;
 }
 
 .emotion-2 {
@@ -125,6 +126,7 @@ exports[`Checkbox should render correctly when disabled 1`] = `
   transition: all .2s ease;
   vertical-align: middle;
   width: 24px;
+  min-width: 24px;
 }
 
 .emotion-2 {
@@ -252,6 +254,7 @@ exports[`Checkbox should render correctly when indeterminate 1`] = `
   transition: all .2s ease;
   vertical-align: middle;
   width: 24px;
+  min-width: 24px;
 }
 
 .emotion-2 {
diff --git a/src/components/Select/SelectMulti/__snapshots__/SelectMulti.test.tsx.snap b/src/components/Select/SelectMulti/__snapshots__/SelectMulti.test.tsx.snap
index 352634068..9a345c6dd 100644
--- a/src/components/Select/SelectMulti/__snapshots__/SelectMulti.test.tsx.snap
+++ b/src/components/Select/SelectMulti/__snapshots__/SelectMulti.test.tsx.snap
@@ -568,6 +568,7 @@ exports[`should render correctly when opened 1`] = `
   transition: all .2s ease;
   vertical-align: middle;
   width: 24px;
+  min-width: 24px;
 }
 
 .emotion-2 {
Repository: laboratoriobridge/bold
Pull request #613 (2020-10-15 15:16:19)

Fixed checkbox inputRef


Patch:
diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx
index 57bd15854..9686633fa 100644
--- a/src/components/Checkbox/Checkbox.tsx
+++ b/src/components/Checkbox/Checkbox.tsx
@@ -1,4 +1,5 @@
 import React, { CSSProperties, useEffect, useRef } from 'react'
+import { composeRefs } from '../../util/react'
 
 import { ClassNames, ExternalStyles, focusBoxShadow, Theme, useStyles } from '../../styles'
 import { Omit } from '../../util'
@@ -11,19 +12,19 @@ export interface CheckboxProps extends Omit<InputProps, 'style'> {
 }
 
 export function Checkbox(props: CheckboxProps) {
-  const { label, indeterminate, style, ...rest } = props
+  const { label, indeterminate, style, inputRef, ...rest } = props
   const { classes, css } = useStyles(createStyles)
   const { classes: inputClasses } = useStyles(createInputStyles, classes)
 
-  const inputRef = useRef<HTMLInputElement>()
+  const internalRef = useRef<HTMLInputElement>()
 
   useEffect(() => {
-    inputRef.current.indeterminate = indeterminate
+    internalRef.current.indeterminate = indeterminate
   }, [indeterminate])
 
   return (
     <label className={css(classes.wrapper, props.disabled && classes.disabled, style)}>
-      <Input {...rest} inputRef={inputRef} type='checkbox' className={inputClasses.input} />
+      <Input {...rest} inputRef={composeRefs(internalRef, inputRef)} type='checkbox' className={inputClasses.input} />
       <span className={classes.check} />
       {(label || label === 0) && <span className={classes.label}>{label}</span>}
     </label>


Test patch:
diff --git a/src/components/Checkbox/Checkbox.test.tsx b/src/components/Checkbox/Checkbox.test.tsx
index 9351f9706..8559067a9 100644
--- a/src/components/Checkbox/Checkbox.test.tsx
+++ b/src/components/Checkbox/Checkbox.test.tsx
@@ -1,4 +1,4 @@
-import { render } from '@testing-library/react'
+import { render, fireEvent } from '@testing-library/react'
 import React from 'react'
 
 import { Checkbox } from './Checkbox'
@@ -21,4 +21,13 @@ describe('Checkbox', () => {
     const input = container.querySelector('input')
     expect(input.indeterminate).toEqual(true)
   })
+  it('should use external inputRef', () => {
+    const ref = React.createRef<HTMLInputElement>()
+
+    const { container } = render(<Checkbox label='check' inputRef={ref} checked={false} />)
+    const input = container.querySelector('input')
+    fireEvent(input, new MouseEvent('click'))
+    expect(input.checked).toBeTruthy()
+    expect(ref.current.checked).toBeTruthy()
+  })
 })