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

Form status not correctly preserved #1524

Open
danny0838 opened this issue Aug 2, 2024 · 3 comments
Open

Form status not correctly preserved #1524

danny0838 opened this issue Aug 2, 2024 · 3 comments

Comments

@danny0838
Copy link

danny0838 commented Aug 2, 2024

Describe the bug
The status of some form elements are not correctly preserved in the captured page.

To Reproduce
Steps to reproduce the behavior:

  1. Create the test page and visit it:
    <!DOCTYPE html>
    <meta charset="UTF-8">
    
    <input type="radio" value="a" data-checked='true'>aaa
    <input type="radio" value="b">bbb
    <input type="radio" value="c" checked>ccc
    <input type="radio" value="d" checked data-checked='false'>ddd
    
    <input type="checkbox" value="A" data-checked='true'>AAA
    <input type="checkbox" value="B">BBB
    <input type="checkbox" value="C" checked>CCC
    <input type="checkbox" value="D" checked data-checked='false'>DDD
    <input type="checkbox" value="E" checked data-indeterminate='true'>EEE
    
    <select>
    <option value="1" data-selected='true'>value1</option>
    <option value="2" selected>value2</option>
    </select>
    
    <script>
    for (const elem of document.querySelectorAll('*')) {
      for (const key in elem.dataset) {
        const value = JSON.parse(elem.dataset[key]);
        elem[key] = value;
      }
    }
    </script>
  2. Save the page with default options
  3. Open the saved page

Expected behavior

  1. The radio button ddd is checked but should be unchecked.
  2. The checkbox DDD is checked but should be unchecked.
  3. The checkbox EEE is checked but should be indeterminate.
  4. The option is value2 but should be value1.

Environment

  • OS: Win10
  • Browser: Chrome 127
  • Version: 1.22.54
gildas-lormeau added a commit to gildas-lormeau/single-file-core that referenced this issue Aug 2, 2024
@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Aug 2, 2024

Thank you. I fixed all the issues except the "indeterminate" state of EEE. I'm a little hesitant about this case because it requires the injection of a script in the saved page.

@danny0838
Copy link
Author

I understand your consideration. I don't like scripts either, but I am not against to handle script-driven matters with scripts, which is somehow of more fidelity of the original page.

Even for the the checked/selected/value attributes, reducing IDL into static HTML attribute breaks form resetting, which might be something the user wants to keep, although the form in the saved page is mostly not expected to be submittable.

WebScrapBook has 7 options for form status:

圖片

but I choose so because it's more expected that the saved page be editable and re-savable in WSB. After all SF is not WSB and you can do whatever you want. (BTW forget my broken English, maybe it should better be "states" rather than "status" here? 😆)

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Aug 3, 2024

Indeed, form management in SF is much more limited than in WSB. It's also the kind of problem I need to take some time to think about. The most important thing is that it's registered somewhere, and for that I thank you very much for creating this issue. You've described the problems perfectly (my english is broken too 😋 but I would use "state" in literal translation from french to english).

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

No branches or pull requests

2 participants