Skip to content

Commit

Permalink
DRYD-1305: Add tooltip prop for DateInput (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejritter authored Jun 14, 2024
1 parent cd5c04b commit c20d93b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/DateInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const propTypes = {
// eslint-disable-next-line react/forbid-foreign-prop-types
...BaseDropdownInput.propTypes,
locale: PropTypes.string,
tooltip: PropTypes.string,
onCommit: PropTypes.func,
readOnly: PropTypes.bool,
};

const defaultProps = {
locale: 'en-US',
tooltip: '',
onCommit: undefined,
readOnly: undefined,
};
Expand Down
1 change: 1 addition & 0 deletions src/components/LineInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default class LineInput extends Component {
ref={this.handleRef}
type="text"
value={normalizedValue}
title={remainingProps.tooltip}
/>
);

Expand Down
8 changes: 8 additions & 0 deletions test/specs/components/DateInput.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ describe('DateInput', function suite() {
expect(this.container.querySelector('.react-calendar')).to.equal(null);
});

it('should render with a tooltip when provided', function test() {
const tooltip = 'test';
render(<DateInput tooltip={tooltip} />, this.container);

const input = this.container.querySelector('input');
expect(input.title).to.equal(tooltip);
});

it('should not open on focus', function test() {
render(<DateInput />, this.container);

Expand Down
8 changes: 8 additions & 0 deletions test/specs/components/LineInput.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,12 @@ describe('LineInput', () => {

document.activeElement.should.equal(input);
});

it('should render with a tooltip when provided', function test() {
const tooltip = 'test';
render(<LineInput tooltip={tooltip} />, this.container);

const input = this.container.querySelector('input');
expect(input.title).to.equal(tooltip);
});
});

0 comments on commit c20d93b

Please sign in to comment.