material icon indicating copy to clipboard operation
material copied to clipboard

feat(slider): make changeAmount multiplier configurable when using meta/ctrl/alt with left/right arrow keys

Open androidfreakers opened this issue 9 years ago • 3 comments

Actual Behavior:

  • Slider is changing values 4 times when using with combination of ctrl/alt key.
  • It should change values based on step count.

Angular Versions: *

  • Angular: 1.5.8
  • Angular material 1.1.1

androidfreakers avatar Dec 16 '16 11:12 androidfreakers

I have checked source code for this:

function keydownListener(ev) {
      if (isDisabled()) return;

      var changeAmount;
      if (vertical ? ev.keyCode === $mdConstant.KEY_CODE.DOWN_ARROW : ev.keyCode === $mdConstant.KEY_CODE.LEFT_ARROW) {
        changeAmount = -step;
      } else if (vertical ? ev.keyCode === $mdConstant.KEY_CODE.UP_ARROW : ev.keyCode === $mdConstant.KEY_CODE.RIGHT_ARROW) {
        changeAmount = step;
      }
      changeAmount = invert ? -changeAmount : changeAmount;
      if (changeAmount) {
        if (ev.metaKey || ev.ctrlKey || ev.altKey) {
          changeAmount *= 4;
        }
        ev.preventDefault();
        ev.stopPropagation();
        scope.$evalAsync(function() {
          setModelValue(ngModelCtrl.$viewValue + changeAmount);
        });
      }
    }

It is clear that is was intensional to give such hidden feature. No one knows about the because documentation does not say anything about that.

How can we make this configurable?

androidfreakers avatar Dec 17 '16 07:12 androidfreakers

https://github.com/angular/material/pull/11210 addresses the missing documentation for the Meta, Control, or Alt key behavior.

Leaving this issue open to indicate that we would be open to a PR from the community that allows the multiplier to be configurable (currently hard coded to 4 steps I.e. 4 * step).

Splaktar avatar Apr 08 '18 07:04 Splaktar

This was also mentioned in PR https://github.com/angular/material/pull/11517. Modifiers still do 4 * step and now page up/down do 10 * step.

It would be easy for the community to submit a PR to make the step size multipliers configurable.

Splaktar avatar Dec 31 '18 21:12 Splaktar