Current event handlers is not setting or giving the value

Open
#616 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
frontend

Research direction

Start by reproducing the supplied HTML and _hyperscript handler with multiple country selects. Inspect how set value of me and document.activeElement are resolved during the change event. Done means the duplicate-country alert still appears and the affected select resets to Select Country without relying on document.activeElement.

Written by the indexing model from the issue text.

Description

Thank you carson and community

I have multiple select fields to select countries, if the user selects the same country in another select field then I show an alert and then set the value of that select field to default value.

    <div
      _="on every change in .country-select 
          set currentCountries to value of .country-select
          set alreadySetCountries to []
            repeat for country in currentCountries
              if country is in alreadySetCountries
                alert(`This country has already been selected`)
                set value of document.activeElement to 'Select Country'
              end
              append country to alreadySetCountries
            end
         "
    >
      <select class="select country-select" autocomplete="country" id="country" name="country">
        <option>Select Country</option>
        <option value="AF">Afghanistan</option>
        <option value="AX">Åland Islands</option>
        <option value="DZ">Albania</option>
        ...
    </select>

     <select class="select country-select" autocomplete="country" id="country" name="country">
        <option>Select Country</option>
        <option value="AF">Afghanistan</option>
        <option value="AX">Åland Islands</option>
        <option value="AL">Albania</option>
        ...
    </select>

    ...
</div>

I have to use document.activeElement in the above code to set or receive values because set value of me to 'Select Country' is not working.

Dominant language
JavaScript
Stars
3.8k
Forks
171
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bigskysoftware/_hyperscript

All issues in bigskysoftware/_hyperscript

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.