Skip to content

Commit

Permalink
Fix primefaces#4375: Events forward stopPropagation and preventDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed May 10, 2023
1 parent 067f2b8 commit 182f962
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 71 deletions.
16 changes: 10 additions & 6 deletions components/lib/autocomplete/AutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as React from 'react';
import PrimeReact, { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { SpinnerIcon } from '../icons/spinner';
import { TimesCircleIcon } from '../icons/timescircle';
import { InputText } from '../inputtext/InputText';
import { OverlayService } from '../overlayservice/OverlayService';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, IconUtils, ObjectUtils, UniqueComponentId, ZIndexUtils } from '../utils/Utils';
import { DomHandler, IconUtils, ObjectUtils, UniqueComponentId, ZIndexUtils, classNames } from '../utils/Utils';
import { AutoCompleteBase } from './AutoCompleteBase';
import { AutoCompletePanel } from './AutoCompletePanel';
import { ChevronDownIcon } from '../icons/chevrondown';
import { TimesCircleIcon } from '../icons/timescircle';
import { SpinnerIcon } from '../icons/spinner';

export const AutoComplete = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -129,8 +129,12 @@ export const AutoComplete = React.memo(
props.onChange({
originalEvent: event,
value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: idState,
Expand Down
8 changes: 6 additions & 2 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,12 @@ export const Calendar = React.memo(
props.onChange({
originalEvent: event,
value: newValue,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
10 changes: 7 additions & 3 deletions components/lib/checkbox/Checkbox.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import { useUpdateEffect } from '../hooks/Hooks';
import { CheckIcon } from '../icons/check';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, IconUtils, ObjectUtils } from '../utils/Utils';
import { CheckboxBase } from './CheckboxBase';
import { CheckIcon } from '../icons/check';
export const Checkbox = React.memo(
React.forwardRef((inProps, ref) => {
const props = CheckboxBase.getProps(inProps);
Expand All @@ -26,8 +26,12 @@ export const Checkbox = React.memo(
originalEvent: event,
value: props.value,
checked: value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
type: 'checkbox',
name: props.name,
Expand Down
18 changes: 13 additions & 5 deletions components/lib/chips/Chips.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import { TimesCircleIcon } from '../icons/timescircle';
import { KeyFilter } from '../keyfilter/KeyFilter';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, IconUtils, ObjectUtils } from '../utils/Utils';
import { ChipsBase } from './ChipsBase';
import { TimesCircleIcon } from '../icons/timescircle';

export const Chips = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -37,8 +37,12 @@ export const Chips = React.memo(
props.onChange({
originalEvent: event,
value: values,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down Expand Up @@ -124,8 +128,12 @@ export const Chips = React.memo(
props.onChange({
originalEvent: event,
value: items,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
2 changes: 1 addition & 1 deletion components/lib/colorpicker/ColorPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PrimeReact from '../api/Api';
import { useEventListener, useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { OverlayService } from '../overlayservice/OverlayService';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, ObjectUtils, ZIndexUtils } from '../utils/Utils';
import { DomHandler, ObjectUtils, ZIndexUtils, classNames } from '../utils/Utils';
import { ColorPickerBase } from './ColorPickerBase';
import { ColorPickerPanel } from './ColorPickerPanel';

Expand Down
32 changes: 24 additions & 8 deletions components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ export const Dropdown = React.memo(
props.onBlur({
originalEvent: event.originalEvent,
value: currentValue,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.originalEvent.stopPropagation();
},
preventDefault: () => {
event.originalEvent.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down Expand Up @@ -366,8 +370,12 @@ export const Dropdown = React.memo(
props.onChange({
originalEvent: event.originalEvent,
value: event.target.value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.originalEvent.stopPropagation();
},
preventDefault: () => {
event.originalEvent.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down Expand Up @@ -422,8 +430,12 @@ export const Dropdown = React.memo(
props.onChange({
originalEvent: event,
value: undefined,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand All @@ -444,8 +456,12 @@ export const Dropdown = React.memo(
props.onChange({
originalEvent: event.originalEvent,
value: optionValue,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.originalEvent.stopPropagation();
},
preventDefault: () => {
event.originalEvent.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
10 changes: 7 additions & 3 deletions components/lib/inputmask/InputMask.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { useMountEffect, useUpdateEffect } from '../hooks/Hooks';
import { InputText } from '../inputtext/InputText';
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';
import { DomHandler, ObjectUtils, classNames } from '../utils/Utils';
import { InputMaskBase } from './InputMaskBase';

export const InputMask = React.memo(
Expand Down Expand Up @@ -437,8 +437,12 @@ export const InputMask = React.memo(
props.onChange({
originalEvent: e,
value: defaultBuffer.current !== val ? val : '',
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
e.stopPropagation();
},
preventDefault: () => {
e.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
14 changes: 9 additions & 5 deletions components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import { useMountEffect, useUpdateEffect } from '../hooks/Hooks';
import { AngleDownIcon } from '../icons/angledown';
import { AngleUpIcon } from '../icons/angleup';
import { InputText } from '../inputtext/InputText';
import { Ripple } from '../ripple/Ripple';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, ObjectUtils, IconUtils } from '../utils/Utils';
import { DomHandler, IconUtils, ObjectUtils, classNames } from '../utils/Utils';
import { InputNumberBase } from './InputNumberBase';
import { AngleUpIcon } from '../icons/angleup';
import { AngleDownIcon } from '../icons/angledown';

export const InputNumber = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -893,8 +893,12 @@ export const InputNumber = React.memo(
props.onValueChange({
originalEvent: event,
value: value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
8 changes: 6 additions & 2 deletions components/lib/inputswitch/InputSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const InputSwitch = React.memo(
props.onChange({
originalEvent: event,
value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
18 changes: 13 additions & 5 deletions components/lib/listbox/ListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { FilterService, localeOption } from '../api/Api';
import { useMountEffect } from '../hooks/Hooks';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';
import { DomHandler, ObjectUtils, classNames } from '../utils/Utils';
import { VirtualScroller } from '../virtualscroller/VirtualScroller';
import { ListBoxBase } from './ListBoxBase';
import { ListBoxHeader } from './ListBoxHeader';
Expand Down Expand Up @@ -96,8 +96,12 @@ export const ListBox = React.memo(
props.onChange({
originalEvent: event,
value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down Expand Up @@ -132,8 +136,12 @@ export const ListBox = React.memo(
props.onChange({
originalEvent: event,
value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
16 changes: 10 additions & 6 deletions components/lib/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import PrimeReact, { FilterService } from '../api/Api';
import { useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { TimesIcon } from '../icons/times';
import { TimesCircleIcon } from '../icons/timescircle';
import { OverlayService } from '../overlayservice/OverlayService';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, IconUtils, ObjectUtils, ZIndexUtils } from '../utils/Utils';
import { DomHandler, IconUtils, ObjectUtils, ZIndexUtils, classNames } from '../utils/Utils';
import { MultiSelectBase } from './MultiSelectBase';
import { MultiSelectPanel } from './MultiSelectPanel';
import { TimesCircleIcon } from '../icons/timescircle';
import { TimesIcon } from '../icons/times';
import { ChevronDownIcon } from '../icons/chevrondown';

export const MultiSelect = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -216,8 +216,12 @@ export const MultiSelect = React.memo(
originalEvent: event,
value,
selectedOption,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
8 changes: 6 additions & 2 deletions components/lib/multistatecheckbox/MultiStateCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ export const MultiStateCheckbox = React.memo(
props.onChange({
originalEvent: event,
value: newValue,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
event.stopPropagation();
},
preventDefault: () => {
event.preventDefault();
},
target: {
name: props.name,
id: props.id,
Expand Down
8 changes: 6 additions & 2 deletions components/lib/radiobutton/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const RadioButton = React.memo(
originalEvent: e,
value: props.value,
checked: value,
stopPropagation: () => {},
preventDefault: () => {},
stopPropagation: () => {
e.stopPropagation();
},
preventDefault: () => {
e.preventDefault();
},
target: {
type: 'radio',
name: props.name,
Expand Down
Loading

0 comments on commit 182f962

Please sign in to comment.