Skip to content
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: still resizes after releasing mouse outside window (#340) #373

Closed
wants to merge 1 commit into from

Conversation

in-ch
Copy link
Contributor

@in-ch in-ch commented Jul 17, 2024

Resolves #340

Hello.
Added features to prevent the panel size from changing when the mouse cursor is out of the browser.

Copy link

vercel bot commented Jul 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2024 2:46pm

});
verifyAttribute(leftElement, "data-resize-handle-state", "inactive");
verifyAttribute(rightElement, "data-resize-handle-state", "inactive");
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems to give a false positive. (I can remove the change you made entirely and it will still pass.)

Copy link
Owner

@bvaughn bvaughn Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I also think this fix may make the most sense in the resize handle registry (where other Window event listeners are) but I haven't thought about it much. I'll give it a quick try this afternoon.

Copy link
Owner

@bvaughn bvaughn Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason the test gives a false positive is that the handle is not down when the move event is fired.

That being said, since the test isn't simulating "mouseout" events– I don't think the approach would work anyway. This might be better structured as an e2e test.

I will take a pass at fixing the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the code review.
I will attempt to fix the test so that it works properly. Thank you. 😀

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to leave an update. As I was looking at this the other day, I realize that I already had code in place to handle this (in the resize handler registry) and it mostly seems to work, but it doesn't work in the case of Code Sandbox (probably something specific to iframes seemingly not receiving "pointerleave" events). Might be worth focusing on that use case.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, having just added an iframe– this library seems to work fine. So I'm not sure what it is about Code Sandbox that's different. 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New route was added here: 29cae93

Example test route here

Can be configured via URL args just like the other e2e route but has a wrapper <iframe> which should in theory allow us to repro the behavior reported in #340 but hasn't yet for some reason.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I think I just realized what's going on by accidentally pushing a reference to localhost in my commit. I think the issue is when the iframe is in a different domain than the parent frame. Lemme poke at that a bit more.

Copy link
Owner

@bvaughn bvaughn Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm able to trigger a similar behavior by using sandbox="allow-scripts". I'll move forward from there and try to add a failing e2e test.

Edit 0586271

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out #374; I think I found a fix.

@bvaughn
Copy link
Owner

bvaughn commented Jul 18, 2024

Thank you for the contribution. I ended up fixing this in #374 after looking into it.

@bvaughn bvaughn closed this Jul 18, 2024
@bvaughn
Copy link
Owner

bvaughn commented Jul 18, 2024

Fixed in #374 and released in 2.0.21


❤️ → ☕ givebrian.coffee

@in-ch
Copy link
Contributor Author

in-ch commented Jul 19, 2024

Thank you so much 😀

@bvaughn
Copy link
Owner

bvaughn commented Jul 19, 2024

You are welcome! Thanks for the coffee! 😌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Still resizes after releasing mouse outside window
2 participants