-
Notifications
You must be signed in to change notification settings - Fork 674
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
[BUG] UI: Resizing window can lead to modal closing, losing user inputs #5232
Comments
Thank you for opening your first issue here! 🛠 |
To address the issue where resizing the window causes the "Launch Task" modal to close and lose user inputs, you can implement a solution that preserves the modal state and user inputs across window resizes. This involves storing the modal state and user inputs when the modal is opened and restoring them when the window is resized. Here's how you can do it:
Here's a simplified example of how this could be implemented in JavaScript: // Save modal state and inputs
function saveModalState() {
const modal = document.getElementById('launchTaskModal');
const isOpen = !!modal && modal.style.display === 'block';
const inputs = modal.querySelectorAll('input, textarea');
const inputValues = Array.from(inputs).map(input => input.value);
localStorage.setItem('modalState', JSON.stringify({ isOpen, inputValues }));
}
// Restore modal state and inputs
function restoreModalState() {
const savedState = localStorage.getItem('modalState');
if (savedState) {
const { isOpen, inputValues } = JSON.parse(savedState);
const modal = document.getElementById('launchTaskModal');
const inputs = modal.querySelectorAll('input, textarea');
if (isOpen) {
modal.style.display = 'block';
inputValues.forEach((value, index) => {
if (inputs[index]) inputs[index].value = value;
});
}
}
}
// Example event listeners for window resize, modal open, and modal close
window.addEventListener('resize', restoreModalState);
document.getElementById('yourOpenModalButtonId').addEventListener('click', () => {
document.getElementById('launchTaskModal').style.display = 'block';
saveModalState();
});
document.getElementById('yourCloseModalButtonId').addEventListener('click', () => {
document.getElementById('launchTaskModal').style.display = 'none';
saveModalState();
});
// Restore modal state on page load
document.addEventListener('DOMContentLoaded', restoreModalState); Adjust the code to match your modal's implementation details, such as the correct IDs and how your modal's visibility is managed. This approach ensures that the user's inputs and the modal's open state are preserved during window resizes, addressing the issue you've encountered. Sources
|
Ah, I see what you're saying. Unfortunately my team doesn't have the bandwidth to fix this at the moment but we'll keep this as an active issue in our backlog and perhaps someone from the community can pick it up. |
Describe the bug
If you resize the window with a "Launch Task" modal open, it will close the modal when the layout switches. E.g. making the window snap to the left half of the screen, or a quarter of the screen. This leads to the user inputs disappearing.
Expected behavior
The webpage reflows together with the modal, not deleting my input
Additional context to reproduce
Screenshots
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: