-
Notifications
You must be signed in to change notification settings - Fork 18
Slider value unset #4173
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
Open
Befkadu1
wants to merge
15
commits into
main
Choose a base branch
from
slider-value-unset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Slider value unset #4173
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
39cd53e
chore(translations): add generic translations for `clear-value` & `va…
Kiarokh 02fd434
chore(slider): use sass variables for some colors
Kiarokh c62a179
fix(slider): correctly center align the thumb's value
Kiarokh 7f94912
fix(slider)!: allow the value to be unset
Kiarokh 45266e2
fix(slider): focus the slider after clearing its value
Kiarokh 6b777aa
test(slider): cover the unset state and clear affordance
Kiarokh 1eb95a4
fix(translations): support unmapped and aliased languages
Kiarokh 5876abf
fix(slider): commit the value when the track is pressed while unset
Befkadu1 61338d2
fix(slider): count steps from valuemin when committing a value
Befkadu1 309455d
fix(slider)!: emit null instead of NaN when the value is cleared
Befkadu1 0748049
test(slider): cover press-to-set and the null contract
Befkadu1 4f28310
test(translations): cover translate.get
Befkadu1 0e86f40
fix(slider): keep the clear button legible and its space reserved
Befkadu1 8c07eef
fix(translations): substitute falsy merge-code values
Befkadu1 fc6070a
Merge branch 'main' into slider-value-unset
Kiarokh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { Component, h, Host, State } from '@stencil/core'; | ||
|
|
||
| /** | ||
| * Unsetting the value | ||
| * | ||
| * This slider is initialized *unset*, which means its `value` is `null`. | ||
| * Therefore the thumb rests in the middle, and the value indicator shows a | ||
| * left-right arrow (`↔`) instead of a number. | ||
| * Assistive technologies announce the value as "Value not set". | ||
| * | ||
| * As soon as the user drags the thumb, presses anywhere on the track, or | ||
| * nudges the thumb with the arrow keys, the slider becomes set and the | ||
| * trailing **clear** button becomes active. | ||
| * Pressing it unsets the slider again, emitting `null` on the `change` | ||
| * event — so a handler must accept `number | null`. | ||
| * | ||
| * A `required` slider does not offer the clear button — a required value | ||
| * cannot be unset — but it can still start unset to prompt a first choice. | ||
| * | ||
| * To unset the slider programmatically, set its `value` to `null`. Any other | ||
| * value that is not a finite number — `undefined`, or `NaN` — works too. | ||
| */ | ||
| @Component({ | ||
| tag: 'limel-example-slider-unset', | ||
| shadow: true, | ||
| }) | ||
| export class SliderUnsetExample { | ||
| @State() | ||
| private value: number | null = null; | ||
|
|
||
| public render() { | ||
| return ( | ||
| <Host> | ||
| <limel-slider | ||
| label="Priority" | ||
| value={this.value} | ||
| valuemin={1} | ||
| valuemax={5} | ||
| step={1} | ||
| onChange={this.handleChange} | ||
| /> | ||
| <limel-example-value value={this.value} /> | ||
| </Host> | ||
| ); | ||
| } | ||
|
|
||
| private readonly handleChange = (event: CustomEvent<number | null>) => { | ||
| this.value = event.detail; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Lundalogik/lime-elements
Length of output: 9430
Replace the render array with
<Host>.Import
Hostfrom@stencil/coreand wrap the three top-level elements in one<Host>element. Do not add Reactkeyproperties.🧰 Tools
🪛 React Doctor (0.9.3)
[error] 56-56: Your users can see the wrong data when this array reorders.
Add a stable
keyprop so React can keep list items matched to the right data when the list changes.(jsx-key)
🤖 Prompt for AI Agents
Sources: Coding guidelines, Path instructions