Merge pull request #15093 from calixteman/issue15092
[JS] Update siblings when a field is updated after a calculation (#15092)
This commit is contained in:
		
						commit
						b5fea8ff14
					
				@ -1151,6 +1151,7 @@ class Doc extends PDFObject {
 | 
				
			|||||||
      field.obj.value = field.obj.defaultValue;
 | 
					      field.obj.value = field.obj.defaultValue;
 | 
				
			||||||
      this._send({
 | 
					      this._send({
 | 
				
			||||||
        id: field.obj._id,
 | 
					        id: field.obj._id,
 | 
				
			||||||
 | 
					        siblings: field.obj._siblings,
 | 
				
			||||||
        value: field.obj.defaultValue,
 | 
					        value: field.obj.defaultValue,
 | 
				
			||||||
        formattedValue: null,
 | 
					        formattedValue: null,
 | 
				
			||||||
        selRange: [0, 0],
 | 
					        selRange: [0, 0],
 | 
				
			||||||
 | 
				
			|||||||
@ -163,6 +163,7 @@ class EventDispatcher {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        source.obj._send({
 | 
					        source.obj._send({
 | 
				
			||||||
          id: source.obj._id,
 | 
					          id: source.obj._id,
 | 
				
			||||||
 | 
					          siblings: source.obj._siblings,
 | 
				
			||||||
          value,
 | 
					          value,
 | 
				
			||||||
          selRange: [selStart, selEnd],
 | 
					          selRange: [selStart, selEnd],
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -170,6 +171,7 @@ class EventDispatcher {
 | 
				
			|||||||
    } else if (!event.willCommit) {
 | 
					    } else if (!event.willCommit) {
 | 
				
			||||||
      source.obj._send({
 | 
					      source.obj._send({
 | 
				
			||||||
        id: source.obj._id,
 | 
					        id: source.obj._id,
 | 
				
			||||||
 | 
					        siblings: source.obj._siblings,
 | 
				
			||||||
        value: savedChange.value,
 | 
					        value: savedChange.value,
 | 
				
			||||||
        selRange: [savedChange.selStart, savedChange.selEnd],
 | 
					        selRange: [savedChange.selStart, savedChange.selEnd],
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@ -178,6 +180,7 @@ class EventDispatcher {
 | 
				
			|||||||
      // so just clear the field.
 | 
					      // so just clear the field.
 | 
				
			||||||
      source.obj._send({
 | 
					      source.obj._send({
 | 
				
			||||||
        id: source.obj._id,
 | 
					        id: source.obj._id,
 | 
				
			||||||
 | 
					        siblings: source.obj._siblings,
 | 
				
			||||||
        value: "",
 | 
					        value: "",
 | 
				
			||||||
        formattedValue: null,
 | 
					        formattedValue: null,
 | 
				
			||||||
        selRange: [0, 0],
 | 
					        selRange: [0, 0],
 | 
				
			||||||
@ -193,6 +196,7 @@ class EventDispatcher {
 | 
				
			|||||||
      if (this.runActions(source, source, event, "Format")) {
 | 
					      if (this.runActions(source, source, event, "Format")) {
 | 
				
			||||||
        source.obj._send({
 | 
					        source.obj._send({
 | 
				
			||||||
          id: source.obj._id,
 | 
					          id: source.obj._id,
 | 
				
			||||||
 | 
					          siblings: source.obj._siblings,
 | 
				
			||||||
          formattedValue: event.value?.toString?.(),
 | 
					          formattedValue: event.value?.toString?.(),
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -215,6 +219,7 @@ class EventDispatcher {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      source.obj._send({
 | 
					      source.obj._send({
 | 
				
			||||||
        id: source.obj._id,
 | 
					        id: source.obj._id,
 | 
				
			||||||
 | 
					        siblings: source.obj._siblings,
 | 
				
			||||||
        value: savedValue,
 | 
					        value: savedValue,
 | 
				
			||||||
        formattedValue,
 | 
					        formattedValue,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@ -223,6 +228,7 @@ class EventDispatcher {
 | 
				
			|||||||
      // The value is not valid.
 | 
					      // The value is not valid.
 | 
				
			||||||
      source.obj._send({
 | 
					      source.obj._send({
 | 
				
			||||||
        id: source.obj._id,
 | 
					        id: source.obj._id,
 | 
				
			||||||
 | 
					        siblings: source.obj._siblings,
 | 
				
			||||||
        value: "",
 | 
					        value: "",
 | 
				
			||||||
        formattedValue: null,
 | 
					        formattedValue: null,
 | 
				
			||||||
        selRange: [0, 0],
 | 
					        selRange: [0, 0],
 | 
				
			||||||
@ -320,6 +326,7 @@ class EventDispatcher {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      target.obj._send({
 | 
					      target.obj._send({
 | 
				
			||||||
        id: target.obj._id,
 | 
					        id: target.obj._id,
 | 
				
			||||||
 | 
					        siblings: target.obj._siblings,
 | 
				
			||||||
        value: savedValue,
 | 
					        value: savedValue,
 | 
				
			||||||
        formattedValue,
 | 
					        formattedValue,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
				
			|||||||
@ -1413,7 +1413,7 @@ describe("Interaction", () => {
 | 
				
			|||||||
      await closePages(pages);
 | 
					      await closePages(pages);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it("must check that data-annotation-rotation is correc", async () => {
 | 
					    it("must check that data-annotation-rotation is correct", async () => {
 | 
				
			||||||
      await Promise.all(
 | 
					      await Promise.all(
 | 
				
			||||||
        pages.map(async ([browserName, page]) => {
 | 
					        pages.map(async ([browserName, page]) => {
 | 
				
			||||||
          await page.waitForFunction(
 | 
					          await page.waitForFunction(
 | 
				
			||||||
@ -1444,4 +1444,52 @@ describe("Interaction", () => {
 | 
				
			|||||||
      );
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe("in issue15092.pdf", () => {
 | 
				
			||||||
 | 
					    let pages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    beforeAll(async () => {
 | 
				
			||||||
 | 
					      pages = await loadAndWait("issue15092.pdf", getSelector("39R"));
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    afterAll(async () => {
 | 
				
			||||||
 | 
					      await closePages(pages);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it("must check that a values is correctly updated on a field and its siblings", async () => {
 | 
				
			||||||
 | 
					      await Promise.all(
 | 
				
			||||||
 | 
					        pages.map(async ([browserName, page]) => {
 | 
				
			||||||
 | 
					          await page.waitForFunction(
 | 
				
			||||||
 | 
					            "window.PDFViewerApplication.scriptingReady === true"
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await clearInput(page, getSelector("39R"));
 | 
				
			||||||
 | 
					          await page.type(getSelector("39R"), "123", { delay: 10 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          const prevTotal = await page.$eval(
 | 
				
			||||||
 | 
					            getSelector("43R"),
 | 
				
			||||||
 | 
					            el => el.value
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await clearInput(page, getSelector("42R"));
 | 
				
			||||||
 | 
					          await page.type(getSelector("42R"), "456", { delay: 10 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await page.click(getSelector("45R"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          await page.waitForFunction(
 | 
				
			||||||
 | 
					            `${getQuerySelector("43R")}.value !== "${prevTotal}"`
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					          await page.waitForFunction(
 | 
				
			||||||
 | 
					            `${getQuerySelector("46R")}.value !== "${prevTotal}"`
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          let total = await page.$eval(getSelector("43R"), el => el.value);
 | 
				
			||||||
 | 
					          expect(total).withContext(`In ${browserName}`).toEqual("579.00");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          total = await page.$eval(getSelector("46R"), el => el.value);
 | 
				
			||||||
 | 
					          expect(total).withContext(`In ${browserName}`).toEqual("579.00");
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							@ -529,3 +529,4 @@
 | 
				
			|||||||
!bug1724918.pdf
 | 
					!bug1724918.pdf
 | 
				
			||||||
!issue15053.pdf
 | 
					!issue15053.pdf
 | 
				
			||||||
!bug1675139.pdf
 | 
					!bug1675139.pdf
 | 
				
			||||||
 | 
					!issue15092.pdf
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								test/pdfs/issue15092.pdf
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test/pdfs/issue15092.pdf
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user