-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(popover): use composed path for trigger element target (#24531) #24535
Conversation
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.
Thanks for making this PR! I added a small comment, but this is looking great otherwise. Could we also add a visual regression test? You should be able to use a test in https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/datetime/test/basic/e2e.ts as a basis for the new one. We would probably want to a test that opens datetime in a popover, opens the time picker, and takes a screenshot. That way if the positioning ever regresses we can catch it.
@@ -372,7 +372,7 @@ export class Popover implements ComponentInterface, PopoverInterface { | |||
* was dispatched. | |||
*/ | |||
@Method() | |||
async present(event?: MouseEvent | TouchEvent | PointerEvent): Promise<void> { | |||
async present(event?: MouseEvent | TouchEvent | PointerEvent | Omit<MouseEvent, 'detail'> & { detail: { ionShadowTarget: EventTarget | null; } }): Promise<void> { |
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.
Rather than hack the MouseEvent type, It might make more sense to use CustomEvent since it has detail
built in.
async present(event?: MouseEvent | TouchEvent | PointerEvent | Omit<MouseEvent, 'detail'> & { detail: { ionShadowTarget: EventTarget | null; } }): Promise<void> { | |
async present(event?: MouseEvent | TouchEvent | PointerEvent | CustomEvent): Promise<void> { |
And then in your datetime.tsx
, you can do something like:
const customEvent = new CustomEvent('ionShadowTarget', { detail: { ionShadowTarget: ev.target }});
popoverRef.present(customEvent);
Maybe not the most elegant, but ionShadowTarget
is a private API, so we can easily change this if needed.
if I uderstand correct, screenshoots are locate in remote server https://screenshot.ionicframework.com/ and I cant push new screenshoot here. |
Hello @mixalbl4-127, You can see an example of what a screenshot test would look like here: https://github.com/ionic-team/ionic-framework/pull/24616/files#diff-46e1092227a42bc4ac87aadc41a0972deca18562fbb5b4d69b906a96f72e79a8R1. While screenshots are hosted, new tests will upload the new screenshot diffs when they are ran through CI. I would like to close this PR in favor of #24616. I'd like to give you co-author credit (I'll update the commit signature soon). Your patch was extremely helpful and also uncovered another issue with the popover and pickers, that should be patched together. Let me know if you have any issues with closing this PR. |
Closing this PR now that the other PR is merged. Thank you so much for getting the work started here 👍 |
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #24531, #24415
What is the new behavior?
Does this introduce a breaking change?
Other information