Typing numbers into cells with percent formatting in Microsoft excel web client wraps characters vertically
Categories
(Web Compatibility :: Site Reports, defect, P2)
Tracking
(Webcompat Priority:P2, Webcompat Score:6)
People
(Reporter: quantumfox6, Unassigned)
References
()
Details
(Keywords: spec-needed, webcompat:contact-in-progress, webcompat:site-report, Whiteboard: [autowebcompat:processed][autowebcompat:repro-failed])
User Story
platform:windows,mac,linux,android impact:feature-broken configuration:general affects:all branch:release diagnosis-team:dom outreach-assignee:denschub outreach-last-contacted:2024-10-23 user-impact-score:450 autowebcompat-repro-status:failed autowebcompat-repro-reason:login autowebcompat-repro-report-os:all
Attachments
(4 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0
Steps to reproduce:
- Open Microsoft 365 web.
- Open Excel and click on "Blank Workbook."
- Format any cell as a percentage.
- Highlight the cell without double clicking on it (there should be no blinking text cursor).
- Begin typing numbers.
Actual results:
After typing numbers into the highlighted cell formatted as a percentage, the characters are stacked vertically within the cell. The initially typed numbers start at the bottom above the '%' sign and get stacked upward, making the number display in a vertical column instead of horizontally as expected. As far as I can tell, this only occurs in Firefox. Similar behavior seems to have been reported elsewhere over the last few years. See links below:
- https://www.reddit.com/r/excel/comments/s78be1/weird_formatting_on_percentage_formatted_cells/
- https://www.reddit.com/r/firefox/comments/uidc9d/microsoft_excel_online_wraps_percentages_firefox/
Expected results:
The numbers should have been displayed horizontally in the cell, with the percentage sign (%) at the end of the number, without any vertical stacking or displacement.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 1•2 years ago
|
||
This seems relate to when we allow scripts to run.
Here's a chrome profile https://share.firefox.dev/4elcOKQ. Looking at input related events, we got keypress, where textInput and input got fired while handing the keypress event. After that, two DOMNodeInserted events were fired.
Now looking at a firefox profile https://share.firefox.dev/4e0hWEq, while we were handling the keypress event, we were allowed to fire not only the textInput and input events, but also two DOMNodeInserted events.
Given this is a custom editor, the above seems related. Thoughts Olli?
Comment 2•2 years ago
|
||
So the difference is mutation events? (which are deprecated)
But I don't know. Needs some debugging ;)
Comment 3•2 years ago
|
||
I still the same broken behaviour when spoofing as Chrome.
Comment 4•2 years ago
|
||
I also see DOMNodeInserted events firing event breakpoints in the debugger and in the profiler in Chrome: https://share.firefox.dev/47qFpML
Sean, maybe DOM mutation events were just turned off for you in Chrome? https://chromestatus.com/feature/5083947249172480
Comment 5•2 years ago
|
||
I also see those DOMNodeInserted, but I don't see them running synchronously along with the keypress event handler in Chrome. I see we run them synchronously in Firefox. I looked into this a bit more and this is hard to debug for me.
Given this relates html editor, masayuki might be able to tell something here?
Comment 6•2 years ago
|
||
I've been looking at this in Replay and can confirm that things seem to be confused pretty early on in the pipeline.
There's a
<div class="ql-editor ewa-rteTextElement" data-gramm="false" spellcheck="false" autocomplete="false" autocorrect="off" role="textbox" tabindex="0" dir="auto" id="gridKeyboardContentEditable_textElement" aria-owns="m_excelWebRenderer_ewaCtl_readoutElement1 m_excelWebRenderer_ewaCtl_readoutElement2" style="font-size: 11pt; font-family: Aptos Narrow; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; padding-left: 2px;" aria-multiline="false" contenteditable="true">
and it gets content inside that looks like:
<div class="ewa-rteLine">
5
</div>
<div class="ewa-rteLine">
4
</div>
<div class="ewa-rteLine">
3
</div>
<div class="ewa-rteLine">
2
</div>
<div class="ewa-rteLine">
1
</div>
Comment 7•2 years ago
|
||
It looks like this ewa-rteLine DOM stuff is being driven by a DOM MutationObserver inside richTextEditor.min.js
Comment 8•2 years ago
|
||
FYI, with a french azerty keyboard, requiring shift to press numbers, the behavior is the same between firefox and chrome when using Shift+key.
It is only buggy in Firefox when using Capslock.
I imagine it doesn't change the underlying issue, but may help identify the broken codepath.
It is the one where keypress are processed without any modifier.
Otherwise here is a trace record with DOM method calls:
https://share.firefox.dev/3TTWUzB
Nothing super obvious stands out to me.
But I found the driving logic in:
https://res-1.cdn.office.net/officeonline/x/s/h88F91A61A0D634C4__layouts/App_Scripts/es6/richTextEditor.min.js
Around line 6570 while being pretty printed:
{
key: 'update',
value: function (e) {
var n = arguments.length > 1 &&
void 0 !== arguments[1] ? arguments[1] : [],
o = arguments.length > 2 &&
void 0 !== arguments[2] ? arguments[2] : void 0,
i = this.delta;
We can see in n the buggy mutations, which are then translated into adding new lines when calling a few lines after this.delta = this.getDelta().
These mutations come from e = this.observer.takeRecords() at line 16428.
It most likely relates to the following code, adding nodes in a content editable and then tracking its mutations:
const e = document.createDocumentFragment();
t.replace(/\r\n/g, '\n').split('\n').forEach(
t => {
const r = document.createElement('div');
r.className = ie.editorLineClass,
t ? r.textContent = t : r.appendChild(document.createElement('br')),
e.appendChild(r)
}
),
Object(et.replaceChildren) (this.textElement),
this.textElement.appendChild(e),
I tried to reproduce the issue with a minimal text case, but I can't get the unexpected mutation for the <br> element.
data:text/html,<script>window.onload=()=>{const div = document.querySelector("div"); type(div, ['1']); const observer = new MutationObserver(function() {}); observer.observe(div, { childList: true }); type(div, ['1', '2']);%20 console.log(observer.takeRecords())}; function type(div, array) {const e = document.createDocumentFragment(); for(const txt of array) {const r = document.createElement('div'); r.textContent=txt; e.appendChild(r);} div.replaceChildren(); div.appendChild(e);}</script><div contenteditable=true><div>br/></div></div>
And Microsoft locked my account for suspicious activity... Could it be solely because I used a relay email?
Comment 9•2 years ago
|
||
Chrome stopped dispatching the legacy mutation events if and only if the mutation is caused by their builtin editor.
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/composite_edit_command.cc;l=188;drc=451093bbaf7fe812bf67d27d760f3bb64c92830b
I tried to disable the legacy mutation events with a script blocker, but it does not allow everybody to flush reflow too. Therefore, I couldn't try to propose the change.
If legacy mutation event listeners caused by DOM mutations by our builtin editor, calling stopImmediatePropagation() from intervention before the event listener(s) could fix this.
Comment 10•2 years ago
|
||
Yeah, I can confirm what Alex is seeing. As the MutationObserver records get applied the "quill" gets into the confused state.
Comment 11•2 years ago
|
||
And I also realized that the rich text editor that Excel is using is https://github.com/slab/quill
Comment 12•2 years ago
|
||
The delta format is described here: https://v1.quilljs.com/docs/delta
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
If you run this test case, delete "Foo" and then insert "1" you'll see that we output a single Mutation that adds a node with the text "1" where as Chrome has two Mutations: one to create the node and one to add the text. I think this might be causing a divergence in Quill here: https://github.com/slab/quill/blob/0148738cb22d52808f35873adb620ca56b1ae061/core/editor.js#L195 which ends up ultimately causing the difference.
Updated•2 years ago
|
Comment 15•2 years ago
|
||
Actually, I think I don't think that's the problem anymore. I think it happens earlier.
Comment 16•2 years ago
|
||
If you type "1" into this test case in FF you get 1<div>%</div>. In Chrome you get <div>1%</div>
In Excel it adds divs around the new lines so the line breaking continues to happen for each number.
Comment 17•2 years ago
•
|
||
This version acts a little more like Excel and causes line breaks after every character in Firefox but not in Chrome.
Comment 18•2 years ago
|
||
It's worth noting that I see the same behaviour that Firefox has in Safari in the test cases and in Excel.
Comment 19•2 years ago
|
||
Masayuki, does either of the behaviours seem more correct to you? Do you have a recommendation for how we should proceed?
Comment 20•2 years ago
|
||
Thank you very much for the minimized testcase!
Well, I didn't think that it's caused only by MutationObserver because in my understanding, it works same in all browsers...
I think that the testcase (attachment 9425386 [details]) depends on an odd behavior of builtin editor of Chrome. Therefore, it's hard to fix this issue in the editor module. When typing Chrome, its builtin editor tries to adjust selection to adjacent text node when selection is collapsed not in a text node. IIRC, this behavior is complained by some editor developers. On the other hand, Gecko tries to insert the character with creating a Text node at selection. In the testcase, Selection is collapsed at <div contenteditable> - 0. Therefore, even after a child <div> is inserted into it, typed character is inserted before the new <div>.
So, I think that Excel should update Selection to start of the new text node after inserting the child <div>.
Currently, I have no idea with fixing this with creating an intervention because I have no idea how to get the chance immediately after the mutation after Excel but before our editor handles the keypress.
Comment 21•2 years ago
|
||
I ran a bisection on Chrome to see when they changed their behaviour and got: https://chromium.googlesource.com/chromium/src/+log/109c974af8f517961ee310b99b2463d12b3d0207..80478c4257e298248e380b62e941ab4c2f775b12
https://chromium.googlesource.com/chromium/src/+/80478c4257e298248e380b62e941ab4c2f775b12 seems like the most likely candidate and it seems like the behaviour change was unintentional
Comment 22•2 years ago
|
||
Yeah, looks like that there was a crash bug to access unexpected memory address due to unexpected selection range and they tried to avoid that with "normalizing" selection range to the nearest text node.
Comment 23•2 years ago
|
||
ni? myself to reach out to Microsoft, here. This still would need some spec-clarification, but MS could work around that.
Updated•2 years ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•8 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 24•2 months ago
|
||
I have been religiously harassing microsoft support by submitting a ticket a week about this for the last 2 years, all of their agents told me "we don't support firefox" but that's a bs excuse so I kept submitting, every single week, for 2 god damn years. Today they rolled out a fix. You're welcome.
Description
•