@spectrum-web-components/number-field 0.42.4 → 0.42.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@ import {
4
4
  aTimeout,
5
5
  elementUpdated,
6
6
  expect,
7
- fixture,
8
7
  nextFrame,
9
8
  oneEvent
10
9
  } from "@open-wc/testing";
@@ -34,7 +33,11 @@ import { spy } from "sinon";
34
33
  import { clickBySelector, getElFrom } from "./helpers.js";
35
34
  import { createLanguageContext } from "../../../tools/reactive-controllers/test/helpers.js";
36
35
  import { sendMouse } from "../../../test/plugins/browser.js";
37
- import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
36
+ import {
37
+ fixture,
38
+ testForLitDevWarnings
39
+ } from "../../../test/testing-helpers.js";
40
+ import { isMac } from "@spectrum-web-components/shared/src/platform.js";
38
41
  describe("NumberField", () => {
39
42
  before(async () => {
40
43
  const shouldPolyfillEn = shouldPolyfill("en");
@@ -838,6 +841,87 @@ describe("NumberField", () => {
838
841
  expect(el.valueAsString).to.equal("17");
839
842
  expect(el.value).to.equal(17);
840
843
  });
844
+ it("does not select all on click based `focus`", async function() {
845
+ this.retries(0);
846
+ const modifier = isMac() ? "Meta" : "Control";
847
+ const el = await getElFrom(units({ value: 17 }));
848
+ expect(el.value).to.equal(17);
849
+ const rect = el.focusElement.getBoundingClientRect();
850
+ await sendMouse({
851
+ steps: [
852
+ {
853
+ type: "click",
854
+ position: [
855
+ rect.left + rect.width / 8,
856
+ rect.top + rect.height / 2
857
+ ]
858
+ }
859
+ ]
860
+ });
861
+ await nextFrame();
862
+ await nextFrame();
863
+ await nextFrame();
864
+ await nextFrame();
865
+ await elementUpdated(el);
866
+ expect(el.focused).to.be.true;
867
+ await sendKeys({
868
+ press: `${modifier}+KeyC`
869
+ });
870
+ await nextFrame();
871
+ await nextFrame();
872
+ await elementUpdated(el);
873
+ await sendKeys({
874
+ press: "ArrowRight"
875
+ });
876
+ await nextFrame();
877
+ await nextFrame();
878
+ await elementUpdated(el);
879
+ await sendKeys({
880
+ press: `${modifier}+KeyV`
881
+ });
882
+ await nextFrame();
883
+ await nextFrame();
884
+ await elementUpdated(el);
885
+ expect(el.value, "copy/paste changed the value").to.equal(17);
886
+ });
887
+ it("selects all on `Tab` based `focus`", async function() {
888
+ this.retries(0);
889
+ const modifier = isMac() ? "Meta" : "Control";
890
+ const el = await getElFrom(units({ value: 17 }));
891
+ const input = document.createElement("input");
892
+ el.insertAdjacentElement("beforebegin", input);
893
+ input.focus();
894
+ await sendKeys({
895
+ press: "Tab"
896
+ });
897
+ await nextFrame();
898
+ await nextFrame();
899
+ await nextFrame();
900
+ await nextFrame();
901
+ await elementUpdated(el);
902
+ expect(el.focused).to.be.true;
903
+ await sendKeys({
904
+ press: `${modifier}+KeyC`
905
+ });
906
+ await nextFrame();
907
+ await nextFrame();
908
+ await elementUpdated(el);
909
+ await sendKeys({
910
+ press: "ArrowRight"
911
+ });
912
+ await nextFrame();
913
+ await nextFrame();
914
+ await elementUpdated(el);
915
+ await sendKeys({
916
+ press: `${modifier}+KeyV`
917
+ });
918
+ await nextFrame();
919
+ await nextFrame();
920
+ await elementUpdated(el);
921
+ expect(el.value, "copy/paste did not change the value").to.equal(
922
+ 1717
923
+ );
924
+ });
841
925
  it("manages units not supported by the browser", async () => {
842
926
  const el = await getElFrom(pixels({ value: 17 }));
843
927
  expect(el.formattedValue).to.equal("17px");