Giter Club home page Giter Club logo

Comments (3)

dosubot avatar dosubot commented on June 6, 2024 2

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:

  1. Save Modal State and Inputs: Create functions to save the current state of the modal and the inputs within it. Use localStorage to store this data.

  2. Restore Modal State and Inputs on Resize: Implement a function that restores the modal state and inputs from localStorage when the window is resized.

  3. Hook into Modal Open/Close Events: Ensure that the modal state is saved every time the modal is opened or closed.

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

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

from flyte.

welcome avatar welcome commented on June 6, 2024

Thank you for opening your first issue here! 🛠

from flyte.

jsonporter avatar jsonporter commented on June 6, 2024

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.

from flyte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.