Bug 166777 - Incorrect Parsing and Truncation of Hexadecimal Color Values with Leading '#' in the "Paragraph Style" dialog box
Summary: Incorrect Parsing and Truncation of Hexadecimal Color Values with Leading '#'...
Status: RESOLVED DUPLICATE of bug 163161
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
25.2.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-29 05:13 UTC by lscfnconsultant
Modified: 2025-05-29 18:03 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lscfnconsultant 2025-05-29 05:13:43 UTC
Component: Styles & Formatting / UI / Color Picker

When attempting to input a hexadecimal color code into the "Hex" input field within the Paragraph Style's Area tab, if the copied hex code includes a leading pound sign (#), as is the case when using the native color picker in Mozilla Firefox, LibreOffice Writer exhibits incorrect parsing behavior. The "Hex" input box has a hard and displayed input limit of 6 characters. Although the leading # is automatically deleted from the input field, it is evidently counted as a character in this 6-character input buffer. This causes the actual six-digit hexadecimal value to be truncated, specifically resulting in the loss of the last hexadecimal digit, which is then incorrectly substituted with a 0.  This forces the user to manually correct the last digit, after finding out what the digit actually is since Firefox automatically copies the value to the clipboard so it is not likely to have been seen or remembered first.


Steps to Reproduce:
    Open LibreOffice Writer.
    Open a document (e.g., a new blank document or a template you are editing).
    Open the Styles deck (Ctrl + F5).
    Go to the Paragraph Styles tab.
    Right-click on any paragraph style (e.g., "Preformatted Text" or "Text Body") and select "Edit Style..."
    Navigate to the "Area" tab.
    Click the "Color" button (under the "Fill" section). This will reveal the "Colors," "Active," and "New" columns.
    Locate the "Hex" input box under the "New" column (below the R, G, B fields).
    Copy a standard 7-character hexadecimal color code (including the leading #) from an external source, such as Firefox's Eyedropper tool.
        Example Code to Use: #e9eef6
    Paste this code into the "Hex" input box.


Observed Behavior:
    The leading # character is automatically deleted from the input field.
    However, due to the 6-character limit and the # being counted, the last digit of the original 6-digit hexadecimal value is incorrectly truncated/dropped, and the field displays the value with a 0 in its place.
        For example, pasting #e9eef6 results in e9eef0 being displayed in the "Hex" input box.
    The "New" color preview box updates to show the color for the incorrectly truncated value (e9eef0), not the intended color (e9eef6).
    The user must manually re-enter the correct last digit to achieve the desired color.
    When manually typing into the "Hex" input box, it strictly enforces the 6-character limit, with subsequent digits being dropped and remaining characters auto-filling with 0s.


Expected Behavior:
    The "Hex" input field should intelligently strip non-hexadecimal characters (like #) without counting them towards the valid 6-digit hexadecimal input.
    When a 7-character hex code (e.g., #RRGGBB) is pasted, the input field should correctly display the full 6-digit hex code (RRGGBB) without any truncation or substitution of valid digits.
    The "New" color preview box should immediately reflect the accurately pasted 6-digit hexadecimal color.
    The input field should allow entry of up to 6 valid hexadecimal characters, handling non-hex characters gracefully (e.g., stripping them without affecting the 6-character limit for valid hex digits).


Impact:
This behavior creates unnecessary friction in the user workflow, requiring a manual remembrance and correction for a common input method. It hinders the ability to precisely and efficiently apply specific colors obtained from web sources.
Comment 1 nutka 2025-05-29 16:29:09 UTC
On Windows : reproducible in components of earlier LO versions too.

See also Bug 163161 ("HexColorControl field validation, remove # when pasting hex value for color")
Comment 2 V Stuart Foote 2025-05-29 18:03:29 UTC

*** This bug has been marked as a duplicate of bug 163161 ***