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

Remove skip-hidden-property option #82

Merged
merged 2 commits into from Jan 3, 2022

Conversation

afcapel
Copy link
Owner

@afcapel afcapel commented Oct 10, 2021

If you need to override the default results show/hide behaviour (for example, as per #61), you can do so with inheritance instead:

import { Autocomplete } from 'stimulus-autocomplete'

export default class extends Autocomplete {

  showResults() {
    this._isHidden = false
    this.element.setAttribute("aria-expanded", "true")
  }

  hideResults() {
    this._isHidden = true
    this.element.setAttribute("aria-expanded", "false")
  }

  get isHidden() {
    return this._isHidden
  }
}

//cc @weaverryan

@weaverryan
Copy link
Contributor

Hi!

I like the new extensions points. However, I don't think the user (who is overriding showResults()) should need to be responsible for managing the "is hidden" flag - I could imagine me overriding these 2 methods to control how we hide/show and not realizing that I just broke the get isHidden() functionality. I don't see a disadvantage to continue to set an isHidden property internally on the controller object.

Cheers!

@afcapel afcapel force-pushed the remove-skip-hidden-property-option branch from 0da231e to 05771c8 Compare November 14, 2021 17:25
@netlify
Copy link

netlify bot commented Nov 14, 2021

✔️ Deploy Preview for stimulus-autocomplete canceled.

🔨 Explore the source changes: a58dc3f

🔍 Inspect the deploy log: https://app.netlify.com/sites/stimulus-autocomplete/deploys/61d342508b8aeb000870e640

Adds an extension point in case someone wants to override the default
behaviour.

This makes skipHiddenProperty unnecesary.
@afcapel afcapel force-pushed the remove-skip-hidden-property-option branch from 05771c8 to c2d3422 Compare November 14, 2021 17:26
@afcapel
Copy link
Owner Author

afcapel commented Nov 14, 2021

@weaverryan fair enough. I've updated the PR so now you can be more specific and atomically the isHidden definition.

Now, if you don't want to hide the results when isHidden = true you could do:

import { Autocomplete } from 'stimulus-autocomplete'

export default class extends Autocomplete {

  set isHidden() {
    this._isHidden = true
  }

  get isHidden() {
    return this._isHidden
  }
}

…operty-option

* origin/main:
  Update README.md
  typo
  Revert "typo"
  typo
@afcapel afcapel merged commit 7240fe1 into main Jan 3, 2022
@afcapel afcapel deleted the remove-skip-hidden-property-option branch January 3, 2022 18:56
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.

None yet

2 participants