-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Update the popover component to rely on useDialog #27675
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
Conversation
|
Size Change: +35 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
|
Sorry, I missed this PR... I already adjusted focus outside in #27700, but had problems with the other two. |
4793a66 to
706d86e
Compare
| } else if ( ! onClickOutside ) { | ||
| if ( onClose ) { | ||
| onClose(); | ||
| } else if ( type === 'focusoutside' && onClickOutside ) { |
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.
Do you think we can somehow removing this now? How long has it been deprecated?
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.
That's a good question, I don't really know but I think at some point we should start having some regular schedule. If something have been reprecated in the WP version v - 10 (just example), remove it. Something we might want to discuss in #core-js cc @gziolo
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.
Right. Especially for code that hard to maintain like this. I'm not sure if this code is even tested anywhere?
|
There's a lot of failures in e2e tests :( Feeling demotivated now, but I'll circle back to the PR later. |
|
Let's do it in smaller steps. I reopened the PR (#27707) I made yesterday, which just removes the HoCs and replaces it with the corresponding hooks. It's all green, so I'll merge so this can be rebased. |
706d86e to
2138feb
Compare
51d57aa to
8897a58
Compare
|
@talldan @ellatrix I might need some help here. It seems the nested popover onFocusOutside case is not working as expected here (the more menu closes when you open the preferences breaking two e2e tests). I have no idea why though, since this change is supposed to do the exact same things as master. |
762a682 to
fc7ffdd
Compare
|
@ellatrix I finally got back to this PR and made everything pass properly. Mind ✅in it? |
| // Ideally the popover should have just a single onClose prop and | ||
| // not three props that potentially do the same thing. | ||
| if ( type === 'focus-outside' && onFocusOutside ) { | ||
| onFocusOutside( event ); |
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.
Should we deprecate this in the future as well, in favour of onClose?
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.
Sounds like something we could try, I'm not certain yet of the impact.
| const [ dialogRef, dialogProps ] = useDialog( { | ||
| focusOnMount, | ||
| __unstableOnClose: onDialogClose, | ||
| onClose: onDialogClose, |
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.
What's the difference between these two?
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.
I also mean: do we need to set both here?
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.
Ideally we should remove __unstableOnClose it's there because Popover need to differentiate between the closing when it happens on focus out and the closing when you use escape... Dialogs in general don't care and if we do your suggestion (merge onFocusOutside and onClose) we should be able to remove the unstable one
ellatrix
left a comment
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.
Looks good to me
Follow-up to #27643
Updates the Popover component to rely on useDialog and remove the duplicated code. I noticed that we have three props in Popover to do the same thing (close the popover): onClickOutside, onFocusOutside and onClose. Ideally we should deprecate the first two ones. The code to keep BC here is not straightforward.