-
-
Notifications
You must be signed in to change notification settings - Fork 651
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
Allow arrow padding to be configured for a step. #3051
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -211,8 +211,13 @@ export function getFloatingUIOptions( | |||||
); | ||||||
|
||||||
if (arrowEl) { | ||||||
const arrowOptions = | ||||||
typeof step.options.arrow === "object" | ||||||
? step.options.arrow | ||||||
: { padding: 4 }; | ||||||
|
||||||
options.middleware.push( | ||||||
arrow({ element: arrowEl, padding: hasEdgeAlignment ? 4 : 0 }) | ||||||
arrow({ element: arrowEl, padding: hasEdgeAlignment ? arrowOptions.padding : 0 }) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
What would you think about putting this inline here? I think it is a little less verbose. |
||||||
); | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,44 @@ describe('components/ShepherdElement', () => { | |
container.querySelectorAll('.shepherd-element .shepherd-arrow').length | ||
).toBe(0); | ||
}); | ||
|
||
it('arrow: object with padding shows arrow', async () => { | ||
const testElement = document.createElement('div'); | ||
const tour = new Tour(); | ||
const step = new Step(tour, { | ||
arrow: { padding: 10 }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding tests! Could we perhaps add an assertion checking that padding of |
||
attachTo: { element: testElement, on: 'top' } | ||
}); | ||
|
||
const { container } = render(ShepherdElement, { | ||
props: { | ||
step | ||
} | ||
}); | ||
|
||
expect( | ||
container.querySelectorAll('.shepherd-element .shepherd-arrow').length | ||
).toBe(1); | ||
}); | ||
|
||
it('arrow: empty object shows arrow', async () => { | ||
const testElement = document.createElement('div'); | ||
const tour = new Tour(); | ||
const step = new Step(tour, { | ||
arrow: {}, | ||
attachTo: { element: testElement, on: 'top' } | ||
}); | ||
|
||
const { container } = render(ShepherdElement, { | ||
props: { | ||
step | ||
} | ||
}); | ||
|
||
expect( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this one, perhaps we could also assert padding, and I think it would be |
||
container.querySelectorAll('.shepherd-element .shepherd-arrow').length | ||
).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('handleKeyDown', () => { | ||
|
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.