Skip to content

Commit

Permalink
fix: use true as contenteditable value on firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Mar 2, 2025
1 parent d317409 commit e969bb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-badgers-see.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@formwerk/core': patch
---

fix: use true as contenteditable value on firefox
5 changes: 4 additions & 1 deletion packages/core/src/useDateTimeField/useDateTimeSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { blockEvent } from '../utils/events';
import { DateTimeSegmentType } from './types';
import { isEditableSegmentType } from './constants';
import { createDisabledContext } from '../helpers/createDisabledContext';
import { isFirefox } from '../utils/platform';

export interface DateTimeSegmentProps {
/**
Expand Down Expand Up @@ -178,10 +179,12 @@ export function useDateTimeSegment(_props: Reactivify<DateTimeSegmentProps>) {
};

const segmentProps = computed(() => {
const ceValue = isFirefox() ? 'true' : 'plaintext-only';

const domProps: DateTimeSegmentDomProps = {
id,
tabindex: isNonEditable() ? -1 : 0,
contenteditable: isNonEditable() ? undefined : 'plaintext-only',
contenteditable: isNonEditable() ? undefined : ceValue,
'aria-disabled': isDisabled.value,
'data-segment-type': toValue(props.type),
'aria-label': isNonEditable() ? undefined : toValue(props.type),
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export function isMac() {

return macRE.test(platform);
}

export function isFirefox() {
return /Firefox/i.test(navigator.userAgent);
}

0 comments on commit e969bb7

Please sign in to comment.