Skip to content

Commit

Permalink
refactor: code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Apr 25, 2023
1 parent 08a034a commit e25456a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Menu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A ``MenuItem`` is its own distinct component that is used by any kind of menu ov
<MenuItem iconBefore={Check}>A Menu Item With an Icon Before</MenuItem>
<MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
<MenuItem disabled>A Disabled Menu Item</MenuItem>
<MenuItem as={Hyperlink} href="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
<MenuItem as="a" href="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
<MenuItem as={Button} variant="tertiary" size="inline">A Button Menu Item</MenuItem>
<MenuItem as={Form.Checkbox}>A Checkbox Menu Item</MenuItem>
</Menu>
Expand Down
3 changes: 1 addition & 2 deletions src/Menu/SelectMenu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { mount } from 'enzyme';
import renderer from 'react-test-renderer';
import { Add, Check } from '../../icons';
import { MenuItem, SelectMenu } from '..';
import Hyperlink from '../Hyperlink';
import Button from '../Button';

const app = document.createElement('div');
Expand All @@ -15,7 +14,7 @@ const selectMenu = mount(
<MenuItem iconBefore={Add}>A Menu Item With an Icon Before</MenuItem>
<MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
<MenuItem disabled>A Disabled Menu Item</MenuItem>
<MenuItem as={Hyperlink} href="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
<MenuItem as="a" href="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
<MenuItem>Falstaff</MenuItem>
<MenuItem>Scipio</MenuItem>
<MenuItem>Faustus</MenuItem>
Expand Down
4 changes: 2 additions & 2 deletions src/Menu/select-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ The ``Modal`` brings focus to the first menu element upon the click of the trigg
<MenuItem iconBefore={Add}>A Menu Item With an Icon Before</MenuItem>
<MenuItem iconAfter={Check}>A Menu Item With an Icon After </MenuItem>
<MenuItem disabled>A Disabled Menu Item</MenuItem>
<MenuItem as={Hyperlink} href="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
<MenuItem as="a" href="https://en.wikipedia.org/wiki/Hyperlink">A Link Menu Item</MenuItem>
</SelectMenu>
```

#### Linked variant

```jsx live
<SelectMenu isLink={true} defaultMessage="Choose Your New Best Friend">
<SelectMenu defaultMessage="Choose Your New Best Friend">
<MenuItem>Falstaff</MenuItem>
<MenuItem>Scipio</MenuItem>
<MenuItem defaultSelected>Faustus</MenuItem>
Expand Down
5 changes: 3 additions & 2 deletions src/Modal/PopperElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function PopperElement({
const {
styles,
attributes,
} = usePopper(target, popperElement, popperOptions);
} = usePopper(target?.current, popperElement, popperOptions);

if (!target) {
return null;
Expand All @@ -30,7 +30,8 @@ PopperElement.defaultProps = {
PopperElement.propTypes = {
children: PropTypes.node,
target: PropTypes.shape({
current: PropTypes.node,
// eslint-disable-next-line react/forbid-prop-types
current: PropTypes.object,
}),
strategy: PropTypes.oneOf(['absolute', 'fixed']),
placement: PropTypes.oneOf([
Expand Down
2 changes: 1 addition & 1 deletion src/Modal/PopperElement.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('<PopperElement />', () => {
</PopperElement>
));
const popperEl = wrapper.find('[data-test="someValue"]');
expect(usePopper).toHaveBeenCalledWith(targetRef, null, defaultPopperOptions);
expect(usePopper).toHaveBeenCalledWith(<div />, null, defaultPopperOptions);
expect(popperEl.length).toBe(1);
expect(popperEl.props().style.someProperty).toBe('someValue');
});
Expand Down
2 changes: 1 addition & 1 deletion src/ProductTour/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
advanceButtonText: tourAdvanceButtonText, dismissButtonText: tourDismissButtonText,
endButtonText: tourEndButtonText,
} = tourValue || {};
const [currentCheckpointData, setCurrentCheckpointData] = useState([]);
const [currentCheckpointData, setCurrentCheckpointData] = useState(null);
const [index, setIndex] = useState(0);
const [isTourEnabled, setIsTourEnabled] = useState(false);
const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);
Expand Down
2 changes: 1 addition & 1 deletion src/SelectableBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const SelectableBox = React.forwardRef(({
tabIndex: -1,
onChange: () => {},
...(type === 'checkbox' ? { ...props, isIndeterminate } : { ...props }),
}, null);
}, false);

useEffect(() => {
if (onClick && inputRef.current) {
Expand Down

0 comments on commit e25456a

Please sign in to comment.