Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date-picker: fix modify props "placement" error #21908

Merged
merged 1 commit into from
Aug 18, 2022
Merged

date-picker: fix modify props "placement" error #21908

merged 1 commit into from
Aug 18, 2022

Conversation

lqzhgood
Copy link
Contributor

@lqzhgood lqzhgood commented Jun 6, 2022

!!! This error is on the current production version 2.15.9 , please quick fix

fix this error
image

vue.runtime.esm.js?2b0e:619 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "placement"

found in

---> <ElDatePicker> at packages/date-picker/src/picker.vue

because this PR #21806 add props placement to erroneously changed "placement" data -> props
detail in issues #21905

  • Make sure you follow Element's contributing guide (中文 | English | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer relative issues for you PR.

this PR #21806 erroneously changed "placement" `data` -> `props`
@sugarnut001
Copy link

The same error...

@55236339
Copy link

55236339 commented Jun 9, 2022

Element UI version fallback to 2.15.7

npm uninstall element-ui
npm i element-ui@2.15.7 -s

@trry-hub
Copy link

trry-hub commented Jun 9, 2022

这个方法并不能解决问题

@cjy816618
Copy link

我也遇到这个问题了

@a1292779206
Copy link

为什么我element 2.15.6也有这个问题

@trry-hub
Copy link

为什么我element 2.15.6也有这个问题

npm uninstall element-ui

npm install element-ui@2.15.6

这样试试,应该能解决你的问题

@akmalov-i
Copy link

Element UI version fallback to 2.15.7

npm uninstall element-ui npm i element-ui@2.15.7 -s

it works!!!!!! THANKS! :3

@fengzhang2011
Copy link

This issue occurs again in 2.15.9.

@joshmakar
Copy link

joshmakar commented Jul 12, 2022

Same warning here

I've updated my package.json file with the following to skip version 2.15.9 which has the props issue. This way when the next release comes out, it will get installed and hopefully not contain the issue.

"element-ui": ">2.15.9 || 2.15.8",

@boluo600
Copy link

boluo600 commented Aug 4, 2022

Version 2.15.8 doesn't have this error, can use it

> npm uninstall element-ui
> npm install element-ui@2.15.8 -s

@xinguanhua xinguanhua merged commit 813abce into ElemeFE:dev Aug 18, 2022
@dhemiwc
Copy link

dhemiwc commented Aug 27, 2022

Removing the prop entirely from the NewPopper might cause some issue no?

Surely replacing the createdAt hook code that sets the value with a prop default value factory function would be more suitable?


const NewPopper = {
  props: {
    appendToBody: Popper.props.appendToBody,
    offset: Popper.props.offset,
    boundariesPadding: Popper.props.boundariesPadding,
    arrowOffset: Popper.props.arrowOffset,
    placement: {
      type: Popper.props.placement.type,
      default: function() {
        return PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
      }
    },
    transformOrigin: Popper.props.transformOrigin
  },
  methods: Popper.methods,
  data() {
    return merge({ visibleArrow: true }, Popper.data);
  },
  beforeDestroy: Popper.beforeDestroy
};

@lqzhgood
Copy link
Contributor Author

Removing the prop entirely from the NewPopper might cause some issue no?

Surely replacing the createdAt hook code that sets the value with a prop default value factory function would be more suitable?


const NewPopper = {
  props: {
    appendToBody: Popper.props.appendToBody,
    offset: Popper.props.offset,
    boundariesPadding: Popper.props.boundariesPadding,
    arrowOffset: Popper.props.arrowOffset,
    placement: {
      type: Popper.props.placement.type,
      default: function() {
        return PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
      }
    },
    transformOrigin: Popper.props.transformOrigin
  },
  methods: Popper.methods,
  data() {
    return merge({ visibleArrow: true }, Popper.data);
  },
  beforeDestroy: Popper.beforeDestroy
};

Your suggestion is good
The difference between them is: placement is a data or props
the placement is not in the docs. if set in props need more test, so I think placement set a data is better.

and the code is 6 years old , I think is not have bug.

this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;


placement show in data is better.

data() {
return {
pickerVisible: false,
showClose: false,
userInput: null,
valueOnOpen: null, // value when picker opens, used to determine whether to emit change
unwatchPickerOptions: null
};

@barry1102
Copy link

俺也一样,别用2.15.9,用2.15.7或者2.15.8

@huangshihu1992
Copy link

Element UI 版本回退到 2.15.7

npm 卸载 element-ui npm i element-ui@2.15.7 -s

it work! thanks!

hzsrc pushed a commit to hzsrc/element that referenced this pull request Feb 2, 2023
this PR ElemeFE#21806 erroneously changed "placement" `data` -> `props`
@xinguanhua
Copy link
Collaborator

@lqzhgood 你好,我是element-ui官方维护团队的xinguanhua,非常感谢你以pr的方式,为element-ui组件库的完善贡献了一份力量。element-ui有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 xinguanhua@gmail.com

@lqzhgood
Copy link
Contributor Author

lqzhgood commented Feb 3, 2023

@lqzhgood 你好,我是 element-ui 官方维护团队的 xinguanhua,非常感谢你以 pr 的方式,为 element-ui 组件库的完善贡献了一份力量。element-ui 有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 xinguanhua@gmail.com

邮件已发送

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet